url
stringlengths
38
157
content
stringlengths
72
15.1M
https://redis.io/docs/latest/commands/slowlog-len/.html
<section class="prose w-full py-12"> <h1 class="command-name"> SLOWLOG LEN </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">SLOWLOG LEN</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 2.2.12 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @admin </code> <span class="mr-1 last:hidden"> , </span> <code> @slow </code> <span class="mr-1 last:hidden"> , </span> <code> @dangerous </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> This command returns the current number of entries in the slow log. </p> <p> A new entry is added to the slow log whenever a command exceeds the execution time threshold defined by the <code> slowlog-log-slower-than </code> configuration directive. The maximum number of entries in the slow log is governed by the <code> slowlog-max-len </code> configuration directive. Once the slog log reaches its maximal size, the oldest entry is removed whenever a new entry is created. The slow log can be cleared with the <a href="/docs/latest/commands/slowlog-reset/"> <code> SLOWLOG RESET </code> </a> command. </p> <h2 id="resp2resp3-reply"> RESP2/RESP3 Reply </h2> <a href="../../develop/reference/protocol-spec#integers"> Integer reply </a> : the number of entries in the slow log. <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/slowlog-len/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/integrate/write-behind/reference/debezium/sqlserver/.html
<section class="prose w-full py-12 max-w-none"> <h1> Write-behind configuration for sqlserver </h1> <p class="text-lg -mt-5 mb-10"> Describes the <code> application.properties </code> settings that configure Debezium Server for sqlserver </p> <h2 id="applicationproperties"> application.properties </h2> <div class="highlight"> <pre class="chroma"><code class="language-properties" data-lang="properties"><span class="line"><span class="cl"><span class="na">debezium.sink.type</span><span class="o">=</span><span class="s">redis</span> </span></span><span class="line"><span class="cl"><span class="na">debezium.sink.redis.message.format</span><span class="o">=</span><span class="s">extended</span> </span></span><span class="line"><span class="cl"><span class="na">debezium.sink.redis.address</span><span class="o">=</span><span class="s">&lt;RDI_HOST&gt;:&lt;RDI_PORT&gt;</span> </span></span><span class="line"><span class="cl"><span class="c1"># Comment the following line if not using a password for Write-behind.</span> </span></span><span class="line"><span class="cl"><span class="na">debezium.sink.redis.password</span><span class="o">=</span><span class="s">&lt;RDI_PASSWORD&gt;</span> </span></span><span class="line"><span class="cl"><span class="na">debezium.sink.redis.memory.limit.mb</span><span class="o">=</span><span class="s">80</span> </span></span><span class="line"><span class="cl"><span class="c1"># Redis SSL/TLS</span> </span></span><span class="line"><span class="cl"><span class="c1">#debezium.sink.redis.ssl.enabled=true</span> </span></span><span class="line"><span class="cl"><span class="c1"># When Redis is configured with a replica shard, these properties allow to verify that the data has been written to the replica.</span> </span></span><span class="line"><span class="cl"><span class="c1">#debezium.sink.redis.wait.enabled=true</span> </span></span><span class="line"><span class="cl"><span class="c1">#debezium.sink.redis.wait.timeout.ms=1000</span> </span></span><span class="line"><span class="cl"><span class="c1">#debezium.sink.redis.wait.retry.enabled=true</span> </span></span><span class="line"><span class="cl"><span class="c1">#debezium.sink.redis.wait.retry.delay.ms=1000</span> </span></span><span class="line"><span class="cl"><span class="c1">#debezium.source.database.history.redis.ssl.enabled=true</span> </span></span><span class="line"><span class="cl"><span class="c1"># Location of the Java keystore file containing an application process' own certificate and private key.</span> </span></span><span class="line"><span class="cl"><span class="c1">#javax.net.ssl.keyStore=&lt;KEY_STORE_FILE_PATH&gt;</span> </span></span><span class="line"><span class="cl"><span class="c1"># Password to access the private key from the keystore file specified by javax.net.ssl.keyStore. This password is used twice: To unlock the keystore file (store password), and To decrypt the private key stored in the keystore (key password).</span> </span></span><span class="line"><span class="cl"><span class="c1">#javax.net.ssl.keyStorePassword=&lt;KEY_STORE_PASSWORD&gt;</span> </span></span><span class="line"><span class="cl"><span class="c1"># Location of the Java keystore file containing the collection of CA certificates trusted by this application process (trust store).</span> </span></span><span class="line"><span class="cl"><span class="c1">#javax.net.ssl.trustStore=&lt;TRUSE_STORE_FILE_PATH&gt;</span> </span></span><span class="line"><span class="cl"><span class="c1"># Password to unlock the keystore file (store password) specified by javax.net.ssl.trustStore.</span> </span></span><span class="line"><span class="cl"><span class="c1">#javax.net.ssl.trustStorePassword=&lt;TRUST_STORE_PASSWORD&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="na">debezium.source.connector.class</span><span class="o">=</span><span class="s">io.debezium.connector.sqlserver.SqlServerConnector</span> </span></span><span class="line"><span class="cl"><span class="na">debezium.source.database.names</span><span class="o">=</span><span class="s">&lt;SOURCE_DB_NAME&gt;</span> </span></span><span class="line"><span class="cl"><span class="na">debezium.source.database.encrypt</span><span class="o">=</span><span class="s">false</span> </span></span><span class="line"><span class="cl"><span class="na">debezium.source.offset.storage</span><span class="o">=</span><span class="s">io.debezium.storage.redis.offset.RedisOffsetBackingStore</span> </span></span><span class="line"><span class="cl"><span class="na">debezium.source.topic.prefix</span><span class="o">=</span><span class="s">&lt;SOURCE_LOGICAL_SERVER_NAME&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="na">debezium.source.database.hostname</span><span class="o">=</span><span class="s">&lt;SOURCE_DB_HOST&gt;</span> </span></span><span class="line"><span class="cl"><span class="na">debezium.source.database.port</span><span class="o">=</span><span class="s">&lt;SOURCE_DB_PORT&gt;</span> </span></span><span class="line"><span class="cl"><span class="na">debezium.source.database.user</span><span class="o">=</span><span class="s">&lt;SOURCE_DB_USER&gt;</span> </span></span><span class="line"><span class="cl"><span class="na">debezium.source.database.password</span><span class="o">=</span><span class="s">&lt;SOURCE_DB_PASSWORD&gt;</span> </span></span><span class="line"><span class="cl"><span class="na">debezium.source.include.schema.changes</span><span class="o">=</span><span class="s">false</span> </span></span><span class="line"><span class="cl"><span class="c1"># Determines whether the connector should omit publishing change events when there are no modifications in the included columns.</span> </span></span><span class="line"><span class="cl"><span class="na">debezium.source.skip.messages.without.change</span><span class="o">=</span><span class="s">true</span> </span></span><span class="line"><span class="cl"><span class="na">debezium.source.offset.flush.interval.ms</span><span class="o">=</span><span class="s">1000</span> </span></span><span class="line"><span class="cl"><span class="na">debezium.source.tombstones.on.delete</span><span class="o">=</span><span class="s">false</span> </span></span><span class="line"><span class="cl"><span class="na">debezium.source.schema.history.internal</span><span class="o">=</span><span class="s">io.debezium.storage.redis.history.RedisSchemaHistory</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1"># Important: Do NOT use `include` and `exclude` table lists at the same time, use either `include` or `exclude`.</span> </span></span><span class="line"><span class="cl"><span class="c1"># An optional, comma-separated list of regular expressions that match fully-qualified table identifiers of tables whose changes you want to capture.</span> </span></span><span class="line"><span class="cl"><span class="c1">#debezium.source.table.include.list=&lt;SCHEMA_NAME.TABLE_NAME1&gt;,&lt;SCHEMA_NAME.TABLE_NAME2&gt;...</span> </span></span><span class="line"><span class="cl"><span class="c1"># An optional, comma-separated list of regular expressions that match fully-qualified table identifiers for tables whose changes you do not want to capture.</span> </span></span><span class="line"><span class="cl"><span class="c1">#debezium.source.table.exclude.list=&lt;SCHEMA_NAME.TABLE_NAME1&gt;,&lt;SCHEMA_NAME.TABLE_NAME2&gt;...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1"># Important: Do NOT use include and exclude column lists at the same time, use either include or exclude.</span> </span></span><span class="line"><span class="cl"><span class="c1"># An optional, comma-separated list of regular expressions that match the fully-qualified names of columns to include in change event record values.</span> </span></span><span class="line"><span class="cl"><span class="c1">#debezium.source.column.include.list=&lt;SCHEMA_NAME.TABLE_NAME.COLUMN_NAME1&gt;,&lt;SCHEMA_NAME.TABLE_NAME.COLUMN_NAME2&gt;...</span> </span></span><span class="line"><span class="cl"><span class="c1"># An optional, comma-separated list of regular expressions that match the fully-qualified names of columns to exclude from change event record values.</span> </span></span><span class="line"><span class="cl"><span class="c1">#debezium.source.column.exclude.list=&lt;SCHEMA_NAME.TABLE_NAME.COLUMN_NAME1&gt;,&lt;SCHEMA_NAME.TABLE_NAME.COLUMN_NAME2&gt;...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1"># Whether to include the detailed schema information generated by Debezium in each record written to RDI.</span> </span></span><span class="line"><span class="cl"><span class="c1"># Note: Including the schema reduces the initial sync throughput and is not recommended for large data sets.</span> </span></span><span class="line"><span class="cl"><span class="na">debezium.source.key.converter.schemas.enable</span><span class="o">=</span><span class="s">false</span> </span></span><span class="line"><span class="cl"><span class="na">debezium.source.value.converter.schemas.enable</span><span class="o">=</span><span class="s">false</span> </span></span><span class="line"><span class="cl"><span class="c1"># When detailed schema information is excluded, handle decimal numeric types as strings.</span> </span></span><span class="line"><span class="cl"><span class="na">debezium.source.decimal.handling.mode</span><span class="o">=</span><span class="s">string</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="na">debezium.transforms</span><span class="o">=</span><span class="s">AddPrefix</span> </span></span><span class="line"><span class="cl"><span class="na">debezium.transforms.AddPrefix.type</span><span class="o">=</span><span class="s">org.apache.kafka.connect.transforms.RegexRouter</span> </span></span><span class="line"><span class="cl"><span class="na">debezium.transforms.AddPrefix.regex</span><span class="o">=</span><span class="s">.*</span> </span></span><span class="line"><span class="cl"><span class="na">debezium.transforms.AddPrefix.replacement</span><span class="o">=</span><span class="s">data:$0</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1"># Logging</span> </span></span><span class="line"><span class="cl"><span class="c1"># Uncomment the following lines if running Debezium Server as a Java standalone process (non-containerized).</span> </span></span><span class="line"><span class="cl"><span class="c1">#quarkus.log.file.enable=true</span> </span></span><span class="line"><span class="cl"><span class="c1">#quarkus.log.file.path=&lt;LOG_FILE_PATH&gt;</span> </span></span><span class="line"><span class="cl"><span class="c1">#quarkus.log.file.rotation.max-file-size=100M</span> </span></span><span class="line"><span class="cl"><span class="c1">#quarkus.log.file.rotation.rotate-on-boot=true</span> </span></span><span class="line"><span class="cl"><span class="c1">#quarkus.log.file.rotation.file-suffix=.yyyy-MM-dd.gz</span> </span></span><span class="line"><span class="cl"><span class="c1">#quarkus.log.file.rotation.max-backup-index=3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1"># The default minimum log level for every log category, change only quarkus.log.level when needed.</span> </span></span><span class="line"><span class="cl"><span class="na">quarkus.log.min-level</span><span class="o">=</span><span class="s">TRACE</span> </span></span><span class="line"><span class="cl"><span class="c1"># The default log level for every log category.</span> </span></span><span class="line"><span class="cl"><span class="na">quarkus.log.level</span><span class="o">=</span><span class="s">INFO</span> </span></span><span class="line"><span class="cl"><span class="c1"># Determine whether to enable the JSON console formatting extension, which disables "normal" console formatting.</span> </span></span><span class="line"><span class="cl"><span class="na">quarkus.log.console.json</span><span class="o">=</span><span class="s">false</span> </span></span><span class="line"><span class="cl"><span class="c1"># The port on which Debezium exposes Microprofile Health endpoint and other exposed status information.</span> </span></span><span class="line"><span class="cl"><span class="na">quarkus.http.port</span><span class="o">=</span><span class="s">8088</span> </span></span></code></pre> </div> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/integrate/write-behind/reference/debezium/sqlserver/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/kubernetes/release-notes/k8s-6-2-8-11-2022-01/.html
<section class="prose w-full py-12 max-w-none"> <h1> Redis Enterprise for Kubernetes Release Notes 6.2.8-11 (January 2022) </h1> <p class="text-lg -mt-5 mb-10"> Support for Istio as ingress controller, K8s 1.22 (AKS, kOps, GKE), OpenShift 4.9 </p> <h2 id="overview"> Overview </h2> <p> The Redis Enterprise K8s 6.2.8-11 release provides support for the <a href="/docs/latest/operate/rs/release-notes/rs-6-2-8-october-2021/"> Redis Enterprise Software release 6.2.8 </a> and includes several enhancements and bug fixes. </p> <p> The key new features, bug fixes, and known limitations are described below. </p> <h2 id="images"> Images </h2> <p> This release includes the following container images: </p> <ul> <li> <strong> Redis Enterprise </strong> : <code> redislabs/redis:6.2.8-53 </code> or <code> redislabs/redis:6.2.8-53.rhel7-openshift </code> </li> <li> <strong> Operator </strong> : <code> redislabs/operator:6.2.8-11 </code> </li> <li> <strong> Services Rigger </strong> : <code> redislabs/k8s-controller:6.2.8-11 </code> or <code> redislabs/services-manager:6.2.8-11 </code> (on the Red Hat registry) </li> </ul> <h2 id="feature-improvements"> Feature improvements </h2> <ul> <li> Istio gateway/virtual services are supported as ingress controllers. Note that for Active-Active databases, the operator doesn't create ingress rules, and those should be manually configured. The version of Istio that was tested is Istio 1.12.0 (RED-64020) </li> <li> Support for K8s 1.22 (AKS, kOps, GKE) and OpenShift 4.9 (RED-64016) </li> <li> Support for pod termination grace period customization in the REC (advanced use case) (RED-67217) </li> <li> Improved security granularity of SCC configuration steps in documentation (RED-67321) </li> <li> Changed behavior when two databases with the same name are created on the cluster. The operator avoids creating a service for them to prevent possible corruption (RED-64535) </li> <li> Improved documentation about changing cluster credentials when using Hashicorp Vault (RED-65304) </li> </ul> <h2 id="fixed-bugs"> Fixed bugs </h2> <ul> <li> Upgraded Go dependencies marked as vulnerable (RED-63858, RED-68651) </li> <li> Avoided flooding operator logs with deprecation notices on K8s 1.21 (RED-67544) </li> <li> Fixed log collector utility issues running on Microsoft Windows (RED-67682) </li> <li> Fixed excessive updates to the RS cluster when using Windows line endings for TLS certificates (RED-67874) </li> </ul> <h2 id="known-limitations"> Known limitations </h2> <h3 id="large-clusters"> Large clusters </h3> <p> On clusters with more than 9 REC nodes, a Kubernetes upgrade can render the Redis cluster unresponsive in some cases. A fix is available in the 6.4.2-5 release. Upgrade your operator version to 6.4.2-5 or later before upgrading your Kubernetes cluster. (RED-93025) </p> <h3 id="upgrading-with-the-bundle-using-kubectl-apply--f-fails-red-69515"> Upgrading with the bundle using <code> kubectl apply -f </code> fails (RED-69515) </h3> <p> Upgrading with the bundle using <code> kubectl apply -f </code> fails, giving the following error: </p> <p> <code> The CustomResourceDefinition "redisenterpriseclusters.app.redislabs.com" is invalid: spec.preserveUnknownFields: Invalid value: true: must be false in order to use defaults in the schema </code> </p> <p> Workaround: Before the upgrade, set the 'spec.preserveUnknownFields` value to false on the REC custom resource. You can use the following command: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl patch crd redisenterpriseclusters.app.redislabs.com -p <span class="s1">$'spec:\n preserveUnknownFields: false'</span> </span></span></code></pre> </div> <h3 id="long-cluster-names-cause-routes-to-be-rejected--red-25871"> Long cluster names cause routes to be rejected (RED-25871) </h3> <p> A cluster name longer than 20 characters will result in a rejected route configuration because the host part of the domain name will exceed 63 characters. The workaround is to limit cluster name to 20 characters or less. </p> <h3 id="cluster-cr-rec-errors-are-not-reported-after-invalid-updates-red-25542"> Cluster CR (REC) errors are not reported after invalid updates (RED-25542) </h3> <p> A cluster CR specification error is not reported if two or more invalid CR resources are updated in sequence. </p> <h3 id="an-unreachable-cluster-has-status-running-red-32805"> An unreachable cluster has status running (RED-32805) </h3> <p> When a cluster is in an unreachable state, the state is still <code> running </code> instead of being reported as an error. </p> <h3 id="readiness-probe-incorrect-on-failures-red-39300"> Readiness probe incorrect on failures (RED-39300) </h3> <p> STS Readiness probe does not mark a node as "not ready" when running <code> rladmin status </code> on node failure. </p> <h3 id="role-missing-on-replica-sets-red-39002"> Role missing on replica sets (RED-39002) </h3> <p> The <code> redis-enterprise-operator </code> role is missing permission on replica sets. </p> <h3 id="private-registries-are-not-supported-on-openshift-311-red-38579"> Private registries are not supported on OpenShift 3.11 (RED-38579) </h3> <p> OpenShift 3.11 does not support DockerHub private registries. This is a known OpenShift issue. </p> <h3 id="internal-dns-and-kubernetes-dns-may-have-conflicts-red-37462"> Internal DNS and Kubernetes DNS may have conflicts (RED-37462) </h3> <p> DNS conflicts are possible between the cluster <code> mdns_server </code> and the K8s DNS. This only impacts DNS resolution from within cluster nodes for Kubernetes DNS names. </p> <h3 id="5410-negatively-impacts-546-red-37233"> 5.4.10 negatively impacts 5.4.6 (RED-37233) </h3> <p> Kubernetes-based 5.4.10 deployments seem to negatively impact existing 5.4.6 deployments that share a Kubernetes cluster. </p> <h3 id="node-cpu-usage-is-reported-instead-of-pod-cpu-usage-red-36884"> Node CPU usage is reported instead of pod CPU usage (RED-36884) </h3> <p> In Kubernetes, the node CPU usage we report on is the usage of the Kubernetes worker node hosting the REC pod. </p> <h3 id="clusters-must-be-named-rec-in-olm-based-deployments-red-39825"> Clusters must be named "rec" in OLM-based deployments (RED-39825) </h3> <p> In OLM-deployed operators, the deployment of the cluster will fail if the name is not "rec". When the operator is deployed via the OLM, the security context constraints (scc) are bound to a specific service account name (i.e., "rec"). The workaround is to name the cluster "rec". </p> <h3 id="rec-clusters-fail-to-start-on-kubernetes-clusters-with-unsynchronized-clocks-red-47254"> REC clusters fail to start on Kubernetes clusters with unsynchronized clocks (RED-47254) </h3> <p> When REC clusters are deployed on Kubernetes clusters with unsynchronized clocks, the REC cluster does not start correctly. The fix is to use NTP to synchronize the underlying K8s nodes. </p> <h3 id="deleting-an-openshift-project-with-an-rec-deployed-may-hang-red-47192"> Deleting an OpenShift project with an REC deployed may hang (RED-47192) </h3> <p> When a REC cluster is deployed in a project (namespace) and has REDB resources, the REDB resources must be deleted first before the REC can be deleted. As such, until the REDB resources are deleted, the project deletion will hang. The fix is to delete the REDB resources first and the REC second. Afterwards, you may delete the project. </p> <h3 id="rec-extralabels-are-not-applied-to-pvcs-on-k8s-versions-115-or-older-red-51921"> REC extraLabels are not applied to PVCs on K8s versions 1.15 or older (RED-51921) </h3> <p> In K8s 1.15 or older, the PVC labels come from the match selectors and not the PVC templates. As such, these versions cannot support PVC labels. If this feature is required, the only fix is to upgrade the K8s cluster to a newer version. </p> <h3 id="hashicorp-vault-integration---no-support-for-gesher-red-55080"> Hashicorp Vault integration - no support for Gesher (RED-55080) </h3> <p> There is no workaround at this time </p> <h3 id="rec-might-report-error-states-on-initial-startup-red-61707"> REC might report error states on initial startup (RED-61707) </h3> <p> There is no workaround at this time except to ignore the errors. </p> <h3 id="pvc-size-issues-when-using-decimal-value-in-spec-red-62132"> PVC size issues when using decimal value in spec (RED-62132) </h3> <p> The workaround for this issue is to make sure you use integer values for the PVC size. </p> <h3 id="following-old-revision-of-quick-start-guide-causes-issues-creating-an-redb-due-to-unrecognized-memory-field-name"> Following old revision of quick start guide causes issues creating an REDB due to unrecognized memory field name </h3> <p> The workaround is to use the newer (current) revision of the quick start document available online. </p> <h2 id="compatibility-notes"> Compatibility Notes </h2> <p> See <a href="/docs/latest/operate/kubernetes/reference/supported_k8s_distributions/"> Supported Kubernetes distributions </a> for the full list of supported distributions. </p> <h3 id="now-supported"> Now supported </h3> <p> This release adds support for the following: </p> <ul> <li> K8s 1.22 for GKE, AKS, and kOps </li> <li> OpenShift 4.9 (uses K8s 1.22) </li> </ul> <h3 id="deprecated"> Deprecated </h3> <ul> <li> Rancher 2.5/K8s 1.17 support is deprecated </li> </ul> <h3 id="no-longer-supported"> No longer supported </h3> <p> This release removes support for the following: </p> <ul> <li> Rancher 2.4 (previously deprecated) </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/kubernetes/release-notes/k8s-6-2-8-11-2022-01/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/references/compatibility/commands/transactions/.html
<section class="prose w-full py-12 max-w-none"> <h1> Transaction commands compatibility </h1> <p class="text-lg -mt-5 mb-10"> Transaction commands compatibility. </p> <p> The following table shows which Redis Community Edition <a href="/docs/latest/commands/?group=transactions"> transaction commands </a> are compatible with standard and Active-Active databases in Redis Enterprise Software and Redis Cloud. </p> <table> <thead> <tr> <th style="text-align:left"> Command </th> <th style="text-align:left"> Redis <br/> Enterprise </th> <th style="text-align:left"> Redis <br/> Cloud </th> <th style="text-align:left"> Notes </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/discard/"> DISCARD </a> </td> <td style="text-align:left"> <span title="Supported"> βœ… Standard </span> <br/> <span title="Supported"> <nobr> βœ… Active-Active </nobr> </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Standard </span> <br/> <span title="Supported"> <nobr> βœ… Active-Active </nobr> </span> </td> <td style="text-align:left"> </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/exec/"> EXEC </a> </td> <td style="text-align:left"> <span title="Supported"> βœ… Standard </span> <br/> <span title="Supported"> <nobr> βœ… Active-Active </nobr> </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Standard </span> <br/> <span title="Supported"> <nobr> βœ… Active-Active </nobr> </span> </td> <td style="text-align:left"> </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/multi/"> MULTI </a> </td> <td style="text-align:left"> <span title="Supported"> βœ… Standard </span> <br/> <span title="Supported"> <nobr> βœ… Active-Active </nobr> </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Standard </span> <br/> <span title="Supported"> <nobr> βœ… Active-Active </nobr> </span> </td> <td style="text-align:left"> </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/unwatch/"> UNWATCH </a> </td> <td style="text-align:left"> <span title="Supported"> βœ… Standard </span> <br/> <span title="Supported"> <nobr> βœ… Active-Active </nobr> </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Standard </span> <br/> <span title="Supported"> <nobr> βœ… Active-Active </nobr> </span> </td> <td style="text-align:left"> </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/watch/"> WATCH </a> </td> <td style="text-align:left"> <span title="Supported"> βœ… Standard </span> <br/> <span title="Supported"> <nobr> βœ… Active-Active </nobr> </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Standard </span> <br/> <span title="Supported"> <nobr> βœ… Active-Active </nobr> </span> </td> <td style="text-align:left"> </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/compatibility/commands/transactions/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/bf.card/.html
<section class="prose w-full py-12"> <h1 class="command-name"> BF.CARD </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">BF.CARD key</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available in: </dt> <dd class="m-0"> <a href="/docs/stack"> Redis Stack </a> / <a href="/docs/data-types/probabilistic"> Bloom 2.4.4 </a> </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) </dd> </dl> <p> Returns the cardinality of a Bloom filter - number of items that were added to a Bloom filter and detected as unique (items that caused at least one bit to be set in at least one sub-filter) </p> <p> (since RedisBloom 2.4.4) </p> <h2 id="required-arguments"> Required arguments </h2> <details open=""> <summary> <code> key </code> </summary> <p> is key name for a Bloom filter. </p> </details> <h2 id="return-value"> Return value </h2> <p> Returns one of these replies: </p> <ul> <li> <a href="/docs/latest/develop/reference/protocol-spec/#integers"> Integer reply </a> - the number of items that were added to this Bloom filter and detected as unique (items that caused at least one bit to be set in at least one sub-filter), or 0 when <code> key </code> does not exist. </li> <li> [] on error (invalid arguments, wrong key type, etc.) </li> </ul> <p> Note: when <code> key </code> exists - return the same value as <code> BF.INFO key ITEMS </code> . </p> <h2 id="examples"> Examples </h2> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis&gt; BF.ADD bf1 item_foo </span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">1</span> </span></span><span class="line"><span class="cl">redis&gt; BF.CARD bf1 </span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">1</span> </span></span><span class="line"><span class="cl">redis&gt; BF.CARD bf_new </span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">0</span></span></span></code></pre> </div> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/bf.card/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/references/rest-api/requests/bdbs/debuginfo/.html
<section class="prose w-full py-12 max-w-none"> <h1> Database debug info requests </h1> <p class="text-lg -mt-5 mb-10"> Documents the Redis Enterprise Software REST API /bdbs/debuginfo requests. </p> <table> <thead> <tr> <th> Method </th> <th> Path </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="#get-all-debuginfo-bdb"> GET </a> </td> <td> <code> /v1/bdbs/debuginfo </code> </td> <td> Get debug info from all databases </td> </tr> <tr> <td> <a href="#get-debuginfo-bdb"> GET </a> </td> <td> <code> /v1/bdbs/{bdb_uid}/debuginfo </code> </td> <td> Get debug info from a specific database </td> </tr> </tbody> </table> <h2 id="get-all-debuginfo-bdb"> Get debug info from all databases </h2> <pre><code>GET /v1/bdbs/debuginfo </code></pre> <p> Downloads a tar file that contains debug info from all databases. </p> <h4 id="required-permissions"> Required permissions </h4> <table> <thead> <tr> <th> Permission name </th> </tr> </thead> <tbody> <tr> <td> <a href="/docs/latest/operate/rs/references/rest-api/permissions/#view_debugging_info"> view_debugging_info </a> </td> </tr> </tbody> </table> <h3 id="get-all-request"> Request </h3> <h4 id="example-http-request"> Example HTTP request </h4> <pre><code>GET /bdbs/debuginfo </code></pre> <h3 id="get-all-response"> Response </h3> <p> Downloads the debug info in a tar file called <code> filename.tar.gz </code> . Extract the files from the tar file to access the debug info. </p> <h4 id="response-headers"> Response headers </h4> <table> <thead> <tr> <th> Key </th> <th> Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> Content-Type </td> <td> application/x-gzip </td> <td> Media type of request/response body </td> </tr> <tr> <td> Content-Length </td> <td> 653350 </td> <td> Length of the response body in octets </td> </tr> <tr> <td> Content-Disposition </td> <td> attachment; filename=debuginfo.tar.gz </td> <td> Display response in browser </td> </tr> </tbody> </table> <h3 id="get-all-status-codes"> Status codes </h3> <table> <thead> <tr> <th> Code </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1"> 200 OK </a> </td> <td> Success. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.1"> 500 Internal Server Error </a> </td> <td> Failed to get debug info. </td> </tr> </tbody> </table> <h2 id="get-debuginfo-bdb"> Get database debug info </h2> <pre><code>GET /v1/bdbs/{int: bdb_uid}/debuginfo </code></pre> <p> Downloads a tar file that contains debug info from the database specified by <code> bdb_uid </code> . </p> <h4 id="required-permissions-1"> Required permissions </h4> <table> <thead> <tr> <th> Permission name </th> </tr> </thead> <tbody> <tr> <td> <a href="/docs/latest/operate/rs/references/rest-api/permissions/#view_debugging_info"> view_debugging_info </a> </td> </tr> </tbody> </table> <h3 id="get-request"> Request </h3> <h4 id="example-http-request-1"> Example HTTP request </h4> <pre><code>GET /bdbs/1/debuginfo </code></pre> <h3 id="get-response"> Response </h3> <p> Downloads the debug info in a tar file called <code> filename.tar.gz </code> . Extract the files from the tar file to access the debug info. </p> <h4 id="response-headers-1"> Response headers </h4> <table> <thead> <tr> <th> Key </th> <th> Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> Content-Type </td> <td> application/x-gzip </td> <td> Media type of request/response body </td> </tr> <tr> <td> Content-Length </td> <td> 653350 </td> <td> Length of the response body in octets </td> </tr> <tr> <td> Content-Disposition </td> <td> attachment; filename=debuginfo.tar.gz </td> <td> Display response in browser </td> </tr> </tbody> </table> <h3 id="get-status-codes"> Status codes </h3> <table> <thead> <tr> <th> Code </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1"> 200 OK </a> </td> <td> Success. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.1"> 500 Internal Server Error </a> </td> <td> Failed to get debug info. </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/rest-api/requests/bdbs/debuginfo/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/json.mget/.html
<section class="prose w-full py-12"> <h1 class="command-name"> JSON.MGET </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">JSON.MGET key [key ...] path</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available in: </dt> <dd class="m-0"> <a href="/docs/stack"> Redis Stack </a> / <a href="/docs/data-types/json"> JSON 1.0.0 </a> </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(M*N) when path is evaluated to a single value where M is the number of keys and N is the size of the value, O(N1+N2+...+Nm) when path is evaluated to multiple values where m is the number of keys and Ni is the size of the i-th key </dd> </dl> <p> Return the values at <code> path </code> from multiple <code> key </code> arguments </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Warning: </div> When cluster mode is enabled, all specified keys must reside on the same <a href="https://redis.io/docs/latest/operate/oss_and_stack/reference/cluster-spec/#key-distribution-model"> hash slot </a> . </div> </div> <p> <a href="#examples"> Examples </a> </p> <h2 id="required-arguments"> Required arguments </h2> <details open=""> <summary> <code> key </code> </summary> <p> is key to parse. Returns <code> null </code> for nonexistent keys. </p> </details> <h2 id="optional-arguments"> Optional arguments </h2> <details open=""> <summary> <code> path </code> </summary> <p> is JSONPath to specify. Returns <code> null </code> for nonexistent paths. </p> </details> <h2 id="return"> Return </h2> <p> JSON.MGET returns an array of bulk string replies specified as the JSON serialization of the value at each key's path. For more information about replies, see <a href="/docs/latest/develop/reference/protocol-spec/"> Redis serialization protocol specification </a> . </p> <h2 id="examples"> Examples </h2> <details open=""> <summary> <b> Return the values at <code> path </code> from multiple <code> key </code> arguments </b> </summary> <p> Create two JSON documents. </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis&gt; JSON.SET doc1 $ <span class="s1">'{"a":1, "b": 2, "nested": {"a": 3}, "c": null}'</span> </span></span><span class="line"><span class="cl">OK </span></span><span class="line"><span class="cl">redis&gt; JSON.SET doc2 $ <span class="s1">'{"a":4, "b": 5, "nested": {"a": 6}, "c": null}'</span> </span></span><span class="line"><span class="cl">OK</span></span></code></pre> </div> <p> Get values from all arguments in the documents. </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis&gt; JSON.MGET doc1 doc2 $..a </span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="s2">"[1,3]"</span> </span></span><span class="line"><span class="cl">2<span class="o">)</span> <span class="s2">"[4,6]"</span></span></span></code></pre> </div> </details> <h2 id="see-also"> See also </h2> <p> <a href="/docs/latest/commands/json.set/"> <code> JSON.SET </code> </a> | <a href="/docs/latest/commands/json.get/"> <code> JSON.GET </code> </a> </p> <h2 id="related-topics"> Related topics </h2> <ul> <li> <a href="/docs/latest/develop/data-types/json/"> RedisJSON </a> </li> <li> <a href="/docs/latest/develop/interact/search-and-query/indexing/"> Index and search JSON documents </a> </li> </ul> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/json.mget/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/kubernetes/re-databases/replica-redb/.html
<section class="prose w-full py-12 max-w-none"> <h1> Create replica databases on Kubernetes </h1> <p class="text-lg -mt-5 mb-10"> How to create and automate database replicas using the database controller </p> <p> You can configure a replica of a database by creating an item in the <code> replicaSources </code> section of the <a href="https://github.com/RedisLabs/redis-enterprise-k8s-docs/blob/master/redis_enterprise_database_api.md#redisenterprisedatabasespec"> Redis Enterprise database specification </a> . The value of <code> replicaSourceType </code> must be 'SECRET'; <code> replicaSourceName </code> must be the name of a secret that contains the replica source url. </p> <p> A secret must be created using a <code> stringData </code> section containing the replica source URI as follows: </p> <div class="highlight"> <pre class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="nt">apiVersion</span><span class="p">:</span><span class="w"> </span><span class="l">v1</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">kind</span><span class="p">:</span><span class="w"> </span><span class="l">Secret</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">metadata</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">my-replica-source</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">stringData</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">uri</span><span class="p">:</span><span class="w"> </span><span class="l">replica-source-uri-goes-here</span><span class="w"> </span></span></span></code></pre> </div> <p> The replica source URL can be retrieved by going to "UI &gt; database &gt; configuration &gt; Press the button Get Replica of source URL" in the administrative UI. But, this information can also be retrieved directly from the REST API as well. </p> <p> A replica of database CR simply uses the secret in the <code> replicaSources </code> section: </p> <div class="highlight"> <pre class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="nt">apiVersion</span><span class="p">:</span><span class="w"> </span><span class="l">app.redislabs.com/v1alpha1</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">kind</span><span class="p">:</span><span class="w"> </span><span class="l">RedisEnterpriseDatabase</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">metadata</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">name-of-replica</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">spec</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">redisEnterpriseCluster</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">name-of-cluster</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">replicaSources</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">replicaSourceType</span><span class="p">:</span><span class="w"> </span><span class="l">SECRET</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">replicaSourceName</span><span class="p">:</span><span class="w"> </span><span class="l">my-replica-source</span><span class="w"> </span></span></span></code></pre> </div> <p> In the above, <code> name-of-replica </code> database will be created as a replica of the source database as long as the source database exists on the source cluster and the secret contains the correct replica source URL for that database. </p> <h2 id="retrieving-the-replica-source-url-via-kubectl"> Retrieving the replica source URL via kubectl </h2> <p> You will need <code> kubectl </code> , <code> curl </code> , and <code> jq </code> installed for this procedure. </p> <ol> <li> <p> Set your metadata: </p> <div class="highlight"> <pre class="chroma"><code class="language-js" data-lang="js"><span class="line"><span class="cl"><span class="nx">CLUSTER_NAME</span><span class="o">=</span><span class="nx">test</span> </span></span><span class="line"><span class="cl"><span class="nx">SOURCE_DB</span><span class="o">=</span><span class="nx">db1</span> </span></span><span class="line"><span class="cl"><span class="nx">TARGET_DB</span><span class="o">=</span><span class="nx">db2</span> </span></span><span class="line"><span class="cl"><span class="nx">TARGET_CLUSTER_NAME</span><span class="o">=</span><span class="nx">test</span> </span></span></code></pre> </div> </li> <li> <p> Retrieve the cluster authentication: </p> <div class="highlight"> <pre class="chroma"><code class="language-js" data-lang="js"><span class="line"><span class="cl"><span class="nx">CLUSTER_USER</span><span class="o">=</span><span class="sb">`kubectl get secret/</span><span class="si">${</span><span class="nx">CLUSTER_NAME</span><span class="si">}</span><span class="sb"> -o json | jq -r .data.username | base64 -d`</span> </span></span><span class="line"><span class="cl"><span class="nx">CLUSTER_PASSWORD</span><span class="o">=</span><span class="sb">`kubectl get secret/</span><span class="si">${</span><span class="nx">CLUSTER_NAME</span><span class="si">}</span><span class="sb"> -o json | jq -r .data.password | base64 -d`</span> </span></span></code></pre> </div> </li> <li> <p> Forward the port of the REST API service for your source cluster: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl port-forward pod/<span class="si">${</span><span class="nv">CLUSTER_NAME</span><span class="si">}</span>-0 <span class="m">9443</span> </span></span></code></pre> </div> </li> <li> <p> Request the information from the REST API: </p> <div class="highlight"> <pre class="chroma"><code class="language-js" data-lang="js"><span class="line"><span class="cl"><span class="nx">JQ</span><span class="o">=</span><span class="s1">'.[] | select(.name=="'</span> </span></span><span class="line"><span class="cl"><span class="nx">JQ</span><span class="o">+=</span><span class="s2">"${SOURCE_DB}"</span> </span></span><span class="line"><span class="cl"><span class="nx">JQ</span><span class="o">+=</span><span class="s1">'") | ("redis://admin:" + .authentication_admin_pass + "@"+.endpoints[0].dns_name+":"+(.endpoints[0].port|tostring))'</span> </span></span><span class="line"><span class="cl"><span class="nx">URI</span><span class="o">=</span><span class="sb">`curl -sf -k -u "$CLUSTER_USER:$CLUSTER_PASSWORD" "https://localhost:9443/v1/bdbs?fields=uid,name,endpoints,authentication_admin_pass" | jq "$JQ" | sed 's/"//g'`</span> </span></span></code></pre> </div> <p> Note: URI now contains the replica source URI. </p> </li> <li> <p> Construct the secret for the replica: </p> <div class="highlight"> <pre class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="l">cat &lt;&lt; EOF &gt; secret.yaml</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">apiVersion</span><span class="p">:</span><span class="w"> </span><span class="l">v1</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">kind</span><span class="p">:</span><span class="w"> </span><span class="l">Secret</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">metadata</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">${SOURCE_DB}-url</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">stringData</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">uri</span><span class="p">:</span><span class="w"> </span><span class="l">${URI}</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="l">EOF</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="l">kubectl apply -f secret.yaml</span><span class="w"> </span></span></span></code></pre> </div> </li> <li> <p> Create the replica database: </p> <div class="highlight"> <pre class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="l">cat &lt;&lt; EOF &gt; target.yaml</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">apiVersion</span><span class="p">:</span><span class="w"> </span><span class="l">app.redislabs.com/v1alpha1</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">kind</span><span class="p">:</span><span class="w"> </span><span class="l">RedisEnterpriseDatabase</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">metadata</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">${TARGET_DB}</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">spec</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">redisEnterpriseCluster</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">${TARGET_CLUSTER_NAME}</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">replicaSources</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">replicaSourceType</span><span class="p">:</span><span class="w"> </span><span class="l">SECRET</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">replicaSourceName</span><span class="p">:</span><span class="w"> </span><span class="l">${SOURCE_DB}-url</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="l">EOF</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="l">kubectl apply -f target.yaml</span><span class="w"> </span></span></span></code></pre> </div> </li> </ol> <h2 id="automating-the-creation-via-a-job"> Automating the creation via a job </h2> <p> The following procedure uses a ConfigMap and a Job to construct the replica source URL secret from the source database and configure the target database. </p> <p> There are four parameters: </p> <ul> <li> <code> source </code> - the name of the source database </li> <li> <code> cluster </code> - the name of the cluster for the source database </li> <li> <code> target </code> - the name of the target database </li> <li> <code> targetCluster </code> - the name of the cluster for the target database </li> </ul> <p> These parameters can be set by: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl create configmap replica-of-database-parameters <span class="se">\ </span></span></span><span class="line"><span class="cl"><span class="se"></span>--from-literal<span class="o">=</span><span class="nv">source</span><span class="o">=</span>name-of-source <span class="se">\ </span></span></span><span class="line"><span class="cl"><span class="se"></span>--from-literal<span class="o">=</span><span class="nv">cluster</span><span class="o">=</span>name-of-cluster <span class="se">\ </span></span></span><span class="line"><span class="cl"><span class="se"></span>--from-literal<span class="o">=</span><span class="nv">target</span><span class="o">=</span>name-of-target <span class="se">\ </span></span></span><span class="line"><span class="cl"><span class="se"></span>--from-literal<span class="o">=</span><span class="nv">targetCluster</span><span class="o">=</span>name-of-cluster </span></span></code></pre> </div> <p> where "name-of-..." is replaced with the database source, source cluster, database target, and target cluster names. </p> <p> The Job and ConfigMap below, when submitted, will create the secret and replica database: </p> <div class="highlight"> <pre class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="nt">apiVersion</span><span class="p">:</span><span class="w"> </span><span class="l">batch/v1</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">kind</span><span class="p">:</span><span class="w"> </span><span class="l">Job</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">metadata</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">replica-of-database</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">spec</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">backoffLimit</span><span class="p">:</span><span class="w"> </span><span class="m">4</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">template</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">spec</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">serviceAccountName</span><span class="p">:</span><span class="w"> </span><span class="l">redis-enterprise-operator</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">restartPolicy</span><span class="p">:</span><span class="w"> </span><span class="l">Never</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">volumes</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">scripts</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">configMap</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">replica-of-database</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">containers</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">createdb</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">image</span><span class="p">:</span><span class="w"> </span><span class="l">debian:stable-slim</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">env</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">MY_NAMESPACE</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">valueFrom</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">fieldRef</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">fieldPath</span><span class="p">:</span><span class="w"> </span><span class="l">metadata.namespace</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">SCRIPT</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">value</span><span class="p">:</span><span class="w"> </span><span class="l">create.sh</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">SOURCE_DB</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">valueFrom</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">configMapKeyRef</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">replica-of-database-parameters</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">key</span><span class="p">:</span><span class="w"> </span><span class="l">source</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">TARGET_DB</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">valueFrom</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">configMapKeyRef</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">replica-of-database-parameters</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">key</span><span class="p">:</span><span class="w"> </span><span class="l">target</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">CLUSTER_SERVICE</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">value</span><span class="p">:</span><span class="w"> </span><span class="l">.svc.cluster.local</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">CLUSTER_NAME</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">valueFrom</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">configMapKeyRef</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">replica-of-database-parameters</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">key</span><span class="p">:</span><span class="w"> </span><span class="l">cluster</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">CLUSTER_PORT</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">value</span><span class="p">:</span><span class="w"> </span><span class="s2">"9443"</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">TARGET_CLUSTER_NAME</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">valueFrom</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">configMapKeyRef</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">replica-of-database-parameters</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">key</span><span class="p">:</span><span class="w"> </span><span class="l">targetCluster</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">volumeMounts</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">mountPath</span><span class="p">:</span><span class="w"> </span><span class="l">/opt/scripts/</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">scripts</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">command</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="l">/bin/bash</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- -<span class="l">c</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="p">|</span><span class="sd"> </span></span></span><span class="line"><span class="cl"><span class="sd"> apt-get update; apt-get install -y curl jq apt-transport-https gnupg2 </span></span></span><span class="line"><span class="cl"><span class="sd"> apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6A030B21BA07F4FB </span></span></span><span class="line"><span class="cl"><span class="sd"> curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - </span></span></span><span class="line"><span class="cl"><span class="sd"> echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | tee -a /etc/apt/sources.list.d/kubernetes.list </span></span></span><span class="line"><span class="cl"><span class="sd"> apt-get update </span></span></span><span class="line"><span class="cl"><span class="sd"> apt-get install -y kubectl </span></span></span><span class="line"><span class="cl"><span class="sd"> bash /opt/scripts/$SCRIPT</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nn">---</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">apiVersion</span><span class="p">:</span><span class="w"> </span><span class="l">v1</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">kind</span><span class="p">:</span><span class="w"> </span><span class="l">ConfigMap</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">metadata</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">replica-of-database</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">data</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">create.sh</span><span class="p">:</span><span class="w"> </span><span class="p">|</span><span class="sd"> </span></span></span><span class="line"><span class="cl"><span class="sd"> CLUSTER_USER=`kubectl get secret/${CLUSTER_NAME} -o json | jq -r .data.username | base64 -d` </span></span></span><span class="line"><span class="cl"><span class="sd"> CLUSTER_PASSWORD=`kubectl get secret/${CLUSTER_NAME} -o json | jq -r .data.password | base64 -d` </span></span></span><span class="line"><span class="cl"><span class="sd"> CLUSTER_HOST=${CLUSTER_NAME}.${MY_NAMESPACE}${CLUSTER_SERVICE} </span></span></span><span class="line"><span class="cl"><span class="sd"> JQ='.[] | select(.name=="' </span></span></span><span class="line"><span class="cl"><span class="sd"> JQ+="${SOURCE_DB}" </span></span></span><span class="line"><span class="cl"><span class="sd"> JQ+='") | ("redis://admin:" + .authentication_admin_pass + "@"+.endpoints[0].dns_name+":"+(.endpoints[0].port|tostring))' </span></span></span><span class="line"><span class="cl"><span class="sd"> URI=`curl -sf -k -u "$CLUSTER_USER:$CLUSTER_PASSWORD" "https://${CLUSTER_HOST}:${CLUSTER_PORT}/v1/bdbs?fields=uid,name,endpoints,authentication_admin_pass" | jq "$JQ" | sed 's/"//g'` </span></span></span><span class="line"><span class="cl"><span class="sd"> echo "URL: ${URL}" </span></span></span><span class="line"><span class="cl"><span class="sd"> echo "" </span></span></span><span class="line"><span class="cl"><span class="sd"> cat &lt;&lt; EOF &gt; /tmp/secret.yaml </span></span></span><span class="line"><span class="cl"><span class="sd"> apiVersion: v1 </span></span></span><span class="line"><span class="cl"><span class="sd"> kind: Secret </span></span></span><span class="line"><span class="cl"><span class="sd"> metadata: </span></span></span><span class="line"><span class="cl"><span class="sd"> name: ${SOURCE_DB}-url </span></span></span><span class="line"><span class="cl"><span class="sd"> stringData: </span></span></span><span class="line"><span class="cl"><span class="sd"> uri: ${URI} </span></span></span><span class="line"><span class="cl"><span class="sd"> EOF </span></span></span><span class="line"><span class="cl"><span class="sd"> cat /tmp/secret.yaml </span></span></span><span class="line"><span class="cl"><span class="sd"> cat &lt;&lt; EOF &gt; /tmp/target.yaml </span></span></span><span class="line"><span class="cl"><span class="sd"> apiVersion: app.redislabs.com/v1alpha1 </span></span></span><span class="line"><span class="cl"><span class="sd"> kind: RedisEnterpriseDatabase </span></span></span><span class="line"><span class="cl"><span class="sd"> metadata: </span></span></span><span class="line"><span class="cl"><span class="sd"> name: ${TARGET_DB} </span></span></span><span class="line"><span class="cl"><span class="sd"> spec: </span></span></span><span class="line"><span class="cl"><span class="sd"> redisEnterpriseCluster: </span></span></span><span class="line"><span class="cl"><span class="sd"> name: ${TARGET_CLUSTER_NAME} </span></span></span><span class="line"><span class="cl"><span class="sd"> replicaSources: </span></span></span><span class="line"><span class="cl"><span class="sd"> - replicaSourceType: SECRET </span></span></span><span class="line"><span class="cl"><span class="sd"> replicaSourceName: ${SOURCE_DB}-url </span></span></span><span class="line"><span class="cl"><span class="sd"> EOF </span></span></span><span class="line"><span class="cl"><span class="sd"> echo "---" </span></span></span><span class="line"><span class="cl"><span class="sd"> cat /tmp/target.yaml </span></span></span><span class="line"><span class="cl"><span class="sd"> echo "" </span></span></span><span class="line"><span class="cl"><span class="sd"> kubectl -n ${MY_NAMESPACE} apply -f /tmp/secret.yaml </span></span></span><span class="line"><span class="cl"><span class="sd"> kubectl -n ${MY_NAMESPACE} apply -f /tmp/target.yaml</span><span class="w"> </span></span></span></code></pre> </div> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/kubernetes/re-databases/replica-redb/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/references/rest-api/objects/job_scheduler/node_checks_job_settings/.html
<section class="prose w-full py-12 max-w-none"> <h1> Node checks job settings object </h1> <p class="text-lg -mt-5 mb-10"> Documents the node_checks_job_settings object used with Redis Enterprise Software REST API calls. </p> <table> <thead> <tr> <th> Name </th> <th> Type/Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> cron_expression </td> <td> string </td> <td> <a href="https://en.wikipedia.org/wiki/Cron#CRON_expression"> CRON expression </a> that defines the node checks schedule </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/rest-api/objects/job_scheduler/node_checks_job_settings/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/requests/bootstrap/validate/.html
<section class="prose w-full py-12 max-w-none"> <h1> Bootstrap validation requests </h1> <p class="text-lg -mt-5 mb-10"> Boostrap validation requests </p> <table> <thead> <tr> <th> Method </th> <th> Path </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="#post-bootstrap-validate"> POST </a> </td> <td> <code> /v1/bootstrap/validate/{action} </code> </td> <td> Perform bootstrap validation </td> </tr> </tbody> </table> <h2 id="post-bootstrap-validate"> Bootstrap validation </h2> <pre><code>POST /v1/bootstrap/validate/{action} </code></pre> <p> Perform bootstrap validation. </p> <p> Unlike actual bootstrapping, this request blocks and immediately returns with a response. </p> <h3 id="post-request"> Request </h3> <h4 id="example-http-request"> Example HTTP request </h4> <pre><code>POST /bootstrap/validate/join_cluster </code></pre> <h4 id="request-body"> Request body </h4> <p> The request must contain a <a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/bootstrap/"> bootstrap configuration object </a> , similar to the one used for actual bootstrapping. </p> <h3 id="post-response"> Response </h3> <p> If an error occurs, the call returns a <code> bootstrap_status </code> JSON object that contains the following fields: </p> <table> <thead> <tr> <th> Field </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> state </td> <td> Current bootstrap state. <br/> <br/> <code> idle </code> : No bootstrapping started. <br/> <br/> <code> initiated </code> : Bootstrap request received. <br/> <br/> <code> creating_cluster </code> : In the process of creating a new cluster. <br/> <br/> <code> joining_cluster </code> : In the process of joining an existing cluster. <br/> <br/> <code> error </code> : The last bootstrap action failed. <br/> <br/> <code> completed </code> : The last bootstrap action completed successfully. </td> </tr> <tr> <td> start_time </td> <td> Bootstrap process start time </td> </tr> <tr> <td> end_time </td> <td> Bootstrap process end time </td> </tr> <tr> <td> error_code </td> <td> If state is <code> error </code> , this error code describes the type of error encountered. </td> </tr> <tr> <td> error_details </td> <td> An error-specific object that may contain additional information about the error. A common field in use is <code> message </code> which provides a more verbose error message. </td> </tr> </tbody> </table> <h3 id="post-status-codes"> Status codes </h3> <table> <thead> <tr> <th> Code </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1"> 200 OK </a> </td> <td> No error, validation was successful. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.7"> 406 Not Acceptable </a> </td> <td> Validation failed, bootstrap status is returned as body. </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/requests/bootstrap/validate/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/kubernetes/re-clusters/connect-to-admin-console/.html
<section class="prose w-full py-12 max-w-none"> <h1> Connect to the admin console </h1> <p class="text-lg -mt-5 mb-10"> Connect to the Redis Enterprise admin console to manage your Redis Enterprise cluster. </p> <p> The username and password for the Redis Enterprise Software <a href="/docs/latest/operate/rs/"> admin console </a> are stored in a Kubernetes <a href="https://kubernetes.io/docs/concepts/configuration/secret/"> secret </a> . After retrieving your credentials, you can use port forwarding to connect to the admin console. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> There are several methods for accessing the admin console. Port forwarding is the simplest, but not the most efficient method for long-term use. You could also use a load balancer service or Ingress. </div> </div> <ol> <li> <p> Switch to the namespace with your Redis Enterprise cluster (REC). </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl config set-context --current --namespace<span class="o">=</span>&lt;namespace-of-rec&gt; </span></span></code></pre> </div> </li> <li> <p> Find your cluster name from your list of secrets. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl get secret </span></span></code></pre> </div> <p> In this example, the cluster name is <code> rec </code> . </p> </li> <li> <p> Extract and decode your credentials from the secret. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl get secret &lt;cluster-name&gt; -o <span class="nv">jsonpath</span><span class="o">=</span><span class="s1">'{.data.username}'</span> <span class="p">|</span> base64 --decode </span></span><span class="line"><span class="cl">kubectl get secret &lt;cluster-name&gt; -o <span class="nv">jsonpath</span><span class="o">=</span><span class="s1">'{.data.password}'</span> <span class="p">|</span> base64 --decode </span></span></code></pre> </div> </li> <li> <p> Find the port for the REC UI service in the <code> spec:ports </code> section of the service definition file. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl get service/&lt;cluster-name&gt;-ui -o yaml </span></span></code></pre> </div> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> <pre><code>The default port is 8443. </code></pre> </div> </div> </li> <li> <p> Use <code> kubectl port-forward </code> to forward your local port to the service port. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl port-forward service/&lt;cluster-name&gt;-ui &lt;local-port&gt;:&lt;service-port&gt; </span></span></code></pre> </div> </li> <li> <p> View the admin console from a web browser on your local machine at <code> https://localhost:8443 </code> . </p> </li> </ol> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/kubernetes/re-clusters/connect-to-admin-console/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/tdigest.cdf.html
<section class="prose w-full py-12"> <h1 class="command-name"> TDIGEST.CDF </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">TDIGEST.CDF key value [value ...]</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available in: </dt> <dd class="m-0"> <a href="/docs/stack"> Redis Stack </a> / <a href="/docs/data-types/probabilistic"> Bloom 2.4.0 </a> </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(N) where N is the number of values specified. </dd> </dl> <p> Returns, for each input value, an estimation of the fraction (floating-point) of (observations smaller than the given value + half the observations equal to the given value). </p> <p> Multiple fractions can be retrieved in a single call. </p> <h2 id="required-arguments"> Required arguments </h2> <details open=""> <summary> <code> key </code> </summary> is key name for an existing t-digest sketch. </details> <details open=""> <summary> <code> value </code> </summary> is value for which the CDF (Cumulative Distribution Function) should be retrieved. </details> <h2 id="return-value"> Return value </h2> <p> <a href="/docs/latest/develop/reference/protocol-spec/#arrays"> Array reply </a> - the command returns an array of floating-points populated with fraction_1, fraction_2, ..., fraction_N. </p> <p> All values are 'nan' if the sketch is empty. </p> <h2 id="examples"> Examples </h2> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis&gt; TDIGEST.CREATE t COMPRESSION <span class="m">1000</span> </span></span><span class="line"><span class="cl">OK </span></span><span class="line"><span class="cl">redis&gt; TDIGEST.ADD t <span class="m">1</span> <span class="m">2</span> <span class="m">2</span> <span class="m">3</span> <span class="m">3</span> <span class="m">3</span> <span class="m">4</span> <span class="m">4</span> <span class="m">4</span> <span class="m">4</span> <span class="m">5</span> <span class="m">5</span> <span class="m">5</span> <span class="m">5</span> <span class="m">5</span> </span></span><span class="line"><span class="cl">OK </span></span><span class="line"><span class="cl">redis&gt; TDIGEST.CDF t <span class="m">0</span> <span class="m">1</span> <span class="m">2</span> <span class="m">3</span> <span class="m">4</span> <span class="m">5</span> <span class="m">6</span> </span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="s2">"0"</span> </span></span><span class="line"><span class="cl">2<span class="o">)</span> <span class="s2">"0.033333333333333333"</span> </span></span><span class="line"><span class="cl">3<span class="o">)</span> <span class="s2">"0.13333333333333333"</span> </span></span><span class="line"><span class="cl">4<span class="o">)</span> <span class="s2">"0.29999999999999999"</span> </span></span><span class="line"><span class="cl">5<span class="o">)</span> <span class="s2">"0.53333333333333333"</span> </span></span><span class="line"><span class="cl">6<span class="o">)</span> <span class="s2">"0.83333333333333337"</span> </span></span><span class="line"><span class="cl">7<span class="o">)</span> <span class="s2">"1"</span></span></span></code></pre> </div> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/tdigest.cdf/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/topk.query.html
<section class="prose w-full py-12"> <h1 class="command-name"> TOPK.QUERY </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">TOPK.QUERY key item [item ...]</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available in: </dt> <dd class="m-0"> <a href="/docs/stack"> Redis Stack </a> / <a href="/docs/data-types/probabilistic"> Bloom 2.0.0 </a> </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(n) where n is the number of items </dd> </dl> <p> Checks whether an item is one of Top-K items. Multiple items can be checked at once. </p> <h3 id="parameters"> Parameters </h3> <ul> <li> <strong> key </strong> : Name of sketch where item is queried. </li> <li> <strong> item </strong> : Item/s to be queried. </li> </ul> <h2 id="return"> Return </h2> <p> <a href="/docs/latest/develop/reference/protocol-spec/#arrays"> Array reply </a> of <a href="/docs/latest/develop/reference/protocol-spec/#integers"> Integer reply </a> - "1" if item is in Top-K, otherwise "0". </p> <h2 id="examples"> Examples </h2> <pre tabindex="0"><code>redis&gt; TOPK.QUERY topk 42 nonexist 1) (integer) 1 2) (integer) 0 </code></pre> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/topk.query/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/smembers/.html
<section class="prose w-full py-12"> <h1 class="command-name"> SMEMBERS </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">SMEMBERS key</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 1.0.0 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(N) where N is the set cardinality. </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @read </code> <span class="mr-1 last:hidden"> , </span> <code> @set </code> <span class="mr-1 last:hidden"> , </span> <code> @slow </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> Returns all the members of the set value stored at <code> key </code> . </p> <p> This has the same effect as running <a href="/docs/latest/commands/sinter/"> <code> SINTER </code> </a> with one argument <code> key </code> . </p> <h2 id="examples"> Examples </h2> <div class="bg-slate-900 border-b border-slate-700 rounded-t-xl px-4 py-3 w-full flex"> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10Z"> </path> </svg> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M10 2.5L18.6603 17.5L1.33975 17.5L10 2.5Z"> </path> </svg> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M10 2.5L12.0776 7.9322L17.886 8.22949L13.3617 11.8841L14.8738 17.5L10 14.3264L5.1262 17.5L6.63834 11.8841L2.11403 8.22949L7.92238 7.9322L10 2.5Z"> </path> </svg> </div> <form class="redis-cli overflow-y-auto max-h-80"> <pre tabindex="0">redis&gt; SADD myset "Hello" (integer) 1 redis&gt; SADD myset "World" (integer) 1 redis&gt; SMEMBERS myset 1) "Hello" 2) "World" </pre> <div class="prompt" style=""> <span> redis&gt; </span> <input autocomplete="off" name="prompt" spellcheck="false" type="text"/> </div> </form> <h2 id="resp2-reply"> RESP2 Reply </h2> <a href="../../develop/reference/protocol-spec#arrays"> Array reply </a> : an array with all the members of the set. <h2 id="resp3-reply"> RESP3 Reply </h2> <a href="../../develop/reference/protocol-spec#sets"> Set reply </a> : a set with all the members of the set. <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/smembers/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/references/rest-api/permissions/.html
<section class="prose w-full py-12 max-w-none"> <h1> Permissions </h1> <p class="text-lg -mt-5 mb-10"> Documents the permissions used with Redis Enterprise Software REST API calls. </p> <p> Some Redis Enterprise <a href="/docs/latest/operate/rs/references/rest-api/requests/"> REST API requests </a> may require the user to have specific permissions. </p> <p> Administrators can assign a predefined role to a user with the <a href="/docs/latest/operate/rs/security/access-control/create-users/"> Cluster Manager UI </a> or a <a href="/docs/latest/operate/rs/references/rest-api/requests/users/#put-user"> <nobr> <code> PUT /users/{uid} </code> </nobr> API request </a> to grant necessary permissions to them. </p> <h2 id="roles"> Roles </h2> <p> Each user in the cluster has an assigned cluster management role, which defines the permissions granted to the user. </p> <p> Available management roles include: </p> <ul> <li> <strong> none </strong> : No REST API permissions. </li> <li> <strong> <a href="#db-viewer-role"> db_viewer </a> </strong> : Can view database info. </li> <li> <strong> <a href="#db-member-role"> db_member </a> </strong> : Can create or modify databases and view their info. </li> <li> <strong> <a href="#cluster-viewer-role"> cluster_viewer </a> </strong> : Can view cluster and database info. </li> <li> <strong> <a href="#cluster-member-role"> cluster_member </a> </strong> : Can modify the cluster and databases and view their info. </li> <li> <strong> <a href="#user-manager-role"> user_manager </a> </strong> : Can modify users and view their info. </li> <li> <strong> <a href="#admin-role"> admin </a> </strong> : Can view and modify all elements of the cluster. </li> </ul> <h2 id="permissions-list-for-each-role"> Permissions list for each role </h2> <table> <thead> <tr> <th> Role </th> <th> Permissions </th> </tr> </thead> <tbody> <tr> <td> none </td> <td> No permissions </td> </tr> <tr> <td> <a name="admin-role"> </a> admin </td> <td> <a href="#add_cluster_module"> add_cluster_module </a> , <a href="#cancel_cluster_action"> cancel_cluster_action </a> , <a href="#cancel_node_action"> cancel_node_action </a> , <a href="#config_ldap"> config_ldap </a> , <a href="#config_ocsp"> config_ocsp </a> , <a href="#create_bdb"> create_bdb </a> , <a href="#create_crdb"> create_crdb </a> , <a href="#create_ldap_mapping"> create_ldap_mapping </a> , <a href="#create_new_user"> create_new_user </a> , <a href="#create_redis_acl"> create_redis_acl </a> , <a href="#create_role"> create_role </a> , <a href="#delete_bdb"> delete_bdb </a> , <a href="#delete_cluster_module"> delete_cluster_module </a> , <a href="#delete_crdb"> delete_crdb </a> , <a href="#delete_ldap_mapping"> delete_ldap_mapping </a> , <a href="#delete_redis_acl"> delete_redis_acl </a> , <a href="#delete_role"> delete_role </a> , <a href="#delete_user"> delete_user </a> , <a href="#edit_bdb_module"> edit_bdb_module </a> , <a href="#failover_shard"> failover_shard </a> , <a href="#flush_crdb"> flush_crdb </a> , <a href="#install_new_license"> install_new_license </a> , <a href="#migrate_shard"> migrate_shard </a> , <a href="#purge_instance"> purge_instance </a> , <a href="#reset_bdb_current_backup_status"> reset_bdb_current_backup_status </a> , <a href="#reset_bdb_current_export_status"> reset_bdb_current_export_status </a> , <a href="#reset_bdb_current_import_status"> reset_bdb_current_import_status </a> , <a href="#start_bdb_export"> start_bdb_export </a> , <a href="#start_bdb_import"> start_bdb_import </a> , <a href="#start_bdb_recovery"> start_bdb_recovery </a> , <a href="#start_cluster_action"> start_cluster_action </a> , <a href="#start_node_action"> start_node_action </a> , <a href="#test_ocsp_status"> test_ocsp_status </a> , <a href="#update_bdb"> update_bdb </a> , <a href="#update_bdb_alerts"> update_bdb_alerts </a> , <a href="#update_bdb_with_action"> update_bdb_with_action </a> , <a href="#update_cluster"> update_cluster </a> , <a href="#update_crdb"> update_crdb </a> , <a href="#update_ldap_mapping"> update_ldap_mapping </a> , <a href="#update_node"> update_node </a> , <a href="#update_proxy"> update_proxy </a> , <a href="#update_redis_acl"> update_redis_acl </a> , <a href="#update_role"> update_role </a> , <a href="#update_user"> update_user </a> , <a href="#view_all_bdb_stats"> view_all_bdb_stats </a> , <a href="#view_all_bdbs_alerts"> view_all_bdbs_alerts </a> , <a href="#view_all_bdbs_info"> view_all_bdbs_info </a> , <a href="#view_all_ldap_mappings_info"> view_all_ldap_mappings_info </a> , <a href="#view_all_nodes_alerts"> view_all_nodes_alerts </a> , <a href="#view_all_nodes_checks"> view_all_nodes_checks </a> , <a href="#view_all_nodes_info"> view_all_nodes_info </a> , <a href="#view_all_nodes_stats"> view_all_nodes_stats </a> , <a href="#view_all_proxies_info"> view_all_proxies_info </a> , <a href="#view_all_redis_acls_info"> view_all_redis_acls_info </a> , <a href="#view_all_roles_info"> view_all_roles_info </a> , <a href="#view_all_shard_stats"> view_all_shard_stats </a> , <a href="#view_all_users_info"> view_all_users_info </a> , <a href="#view_bdb_alerts"> view_bdb_alerts </a> , <a href="#view_bdb_info"> view_bdb_info </a> , <a href="#view_bdb_recovery_plan"> view_bdb_recovery_plan </a> , <a href="#view_bdb_stats"> view_bdb_stats </a> , <a href="#view_cluster_alerts"> view_cluster_alerts </a> , <a href="#view_cluster_info"> view_cluster_info </a> , <a href="#view_cluster_keys"> view_cluster_keys </a> , <a href="#view_cluster_modules"> view_cluster_modules </a> , <a href="#view_cluster_stats"> view_cluster_stats </a> , <a href="#view_crdb"> view_crdb </a> , <a href="#view_crdb_list"> view_crdb_list </a> , <a href="#view_crdb_task"> view_crdb_task </a> , <a href="#view_crdb_task_list"> view_crdb_task_list </a> , <a href="#view_debugging_info"> view_debugging_info </a> , <a href="#view_endpoint_stats"> view_endpoint_stats </a> , <a href="#view_ldap_config"> view_ldap_config </a> , <a href="#view_ldap_mapping_info"> view_ldap_mapping_info </a> , <a href="#view_license"> view_license </a> , <a href="#view_logged_events"> view_logged_events </a> , <a href="#view_node_alerts"> view_node_alerts </a> , <a href="#view_node_check"> view_node_check </a> , <a href="#view_node_info"> view_node_info </a> , <a href="#view_node_stats"> view_node_stats </a> , <a href="#view_ocsp_config"> view_ocsp_config </a> , <a href="#view_ocsp_status"> view_ocsp_status </a> , <a href="#view_proxy_info"> view_proxy_info </a> , <a href="#view_redis_acl_info"> view_redis_acl_info </a> , <a href="#view_redis_pass"> view_redis_pass </a> , <a href="#view_role_info"> view_role_info </a> , <a href="#view_shard_stats"> view_shard_stats </a> , <a href="#view_status_of_all_node_actions"> view_status_of_all_node_actions </a> , <a href="#view_status_of_cluster_action"> view_status_of_cluster_action </a> , <a href="#view_status_of_node_action"> view_status_of_node_action </a> , <a href="#view_user_info"> view_user_info </a> </td> </tr> <tr> <td> <a name="cluster-member-role"> </a> cluster_member </td> <td> <a href="#create_bdb"> create_bdb </a> , <a href="#create_crdb"> create_crdb </a> , <a href="#delete_bdb"> delete_bdb </a> , <a href="#delete_crdb"> delete_crdb </a> , <a href="#edit_bdb_module"> edit_bdb_module </a> , <a href="#failover_shard"> failover_shard </a> , <a href="#flush_crdb"> flush_crdb </a> , <a href="#migrate_shard"> migrate_shard </a> , <a href="#purge_instance"> purge_instance </a> , <a href="#reset_bdb_current_backup_status"> reset_bdb_current_backup_status </a> , <a href="#reset_bdb_current_export_status"> reset_bdb_current_export_status </a> , <a href="#reset_bdb_current_import_status"> reset_bdb_current_import_status </a> , <a href="#start_bdb_export"> start_bdb_export </a> , <a href="#start_bdb_import"> start_bdb_import </a> , <a href="#start_bdb_recovery"> start_bdb_recovery </a> , <a href="#update_bdb"> update_bdb </a> , <a href="#update_bdb_alerts"> update_bdb_alerts </a> , <a href="#update_bdb_with_action"> update_bdb_with_action </a> , <a href="#update_crdb"> update_crdb </a> , <a href="#view_all_bdb_stats"> view_all_bdb_stats </a> , <a href="#view_all_bdbs_alerts"> view_all_bdbs_alerts </a> , <a href="#view_all_bdbs_info"> view_all_bdbs_info </a> , <a href="#view_all_nodes_alerts"> view_all_nodes_alerts </a> , <a href="#view_all_nodes_checks"> view_all_nodes_checks </a> , <a href="#view_all_nodes_info"> view_all_nodes_info </a> , <a href="#view_all_nodes_stats"> view_all_nodes_stats </a> , <a href="#view_all_proxies_info"> view_all_proxies_info </a> , <a href="#view_all_redis_acls_info"> view_all_redis_acls_info </a> , <a href="#view_all_roles_info"> view_all_roles_info </a> , <a href="#view_all_shard_stats"> view_all_shard_stats </a> , <a href="#view_bdb_alerts"> view_bdb_alerts </a> , <a href="#view_bdb_info"> view_bdb_info </a> , <a href="#view_bdb_recovery_plan"> view_bdb_recovery_plan </a> , <a href="#view_bdb_stats"> view_bdb_stats </a> , <a href="#view_cluster_alerts"> view_cluster_alerts </a> , <a href="#view_cluster_info"> view_cluster_info </a> , <a href="#view_cluster_keys"> view_cluster_keys </a> , <a href="#view_cluster_modules"> view_cluster_modules </a> , <a href="#view_cluster_stats"> view_cluster_stats </a> , <a href="#view_crdb"> view_crdb </a> , <a href="#view_crdb_list"> view_crdb_list </a> , <a href="#view_crdb_task"> view_crdb_task </a> , <a href="#view_crdb_task_list"> view_crdb_task_list </a> , <a href="#view_debugging_info"> view_debugging_info </a> , <a href="#view_endpoint_stats"> view_endpoint_stats </a> , <a href="#view_license"> view_license </a> , <a href="#view_logged_events"> view_logged_events </a> , <a href="#view_node_alerts"> view_node_alerts </a> , <a href="#view_node_check"> view_node_check </a> , <a href="#view_node_info"> view_node_info </a> , <a href="#view_node_stats"> view_node_stats </a> , <a href="#view_proxy_info"> view_proxy_info </a> , <a href="#view_redis_acl_info"> view_redis_acl_info </a> , <a href="#view_redis_pass"> view_redis_pass </a> , <a href="#view_role_info"> view_role_info </a> , <a href="#view_shard_stats"> view_shard_stats </a> , <a href="#view_status_of_all_node_actions"> view_status_of_all_node_actions </a> , <a href="#view_status_of_cluster_action"> view_status_of_cluster_action </a> , <a href="#view_status_of_node_action"> view_status_of_node_action </a> </td> </tr> <tr> <td> <a name="cluster-viewer-role"> </a> cluster_viewer </td> <td> <a href="#view_all_bdb_stats"> view_all_bdb_stats </a> , <a href="#view_all_bdbs_alerts"> view_all_bdbs_alerts </a> , <a href="#view_all_bdbs_info"> view_all_bdbs_info </a> , <a href="#view_all_nodes_alerts"> view_all_nodes_alerts </a> , <a href="#view_all_nodes_checks"> view_all_nodes_checks </a> , <a href="#view_all_nodes_info"> view_all_nodes_info </a> , <a href="#view_all_nodes_stats"> view_all_nodes_stats </a> , <a href="#view_all_proxies_info"> view_all_proxies_info </a> , <a href="#view_all_redis_acls_info"> view_all_redis_acls_info </a> , <a href="#view_all_roles_info"> view_all_roles_info </a> , <a href="#view_all_shard_stats"> view_all_shard_stats </a> , <a href="#view_bdb_alerts"> view_bdb_alerts </a> , <a href="#view_bdb_info"> view_bdb_info </a> , <a href="#view_bdb_recovery_plan"> view_bdb_recovery_plan </a> , <a href="#view_bdb_stats"> view_bdb_stats </a> , <a href="#view_cluster_alerts"> view_cluster_alerts </a> , <a href="#view_cluster_info"> view_cluster_info </a> , <a href="#view_cluster_modules"> view_cluster_modules </a> , <a href="#view_cluster_stats"> view_cluster_stats </a> , <a href="#view_crdb"> view_crdb </a> , <a href="#view_crdb_list"> view_crdb_list </a> , <a href="#view_crdb_task"> view_crdb_task </a> , <a href="#view_crdb_task_list"> view_crdb_task_list </a> , <a href="#view_endpoint_stats"> view_endpoint_stats </a> , <a href="#view_license"> view_license </a> , <a href="#view_logged_events"> view_logged_events </a> , <a href="#view_node_alerts"> view_node_alerts </a> , <a href="#view_node_check"> view_node_check </a> , <a href="#view_node_info"> view_node_info </a> , <a href="#view_node_stats"> view_node_stats </a> , <a href="#view_proxy_info"> view_proxy_info </a> , <a href="#view_redis_acl_info"> view_redis_acl_info </a> , <a href="#view_role_info"> view_role_info </a> , <a href="#view_shard_stats"> view_shard_stats </a> , <a href="#view_status_of_all_node_actions"> view_status_of_all_node_actions </a> , <a href="#view_status_of_cluster_action"> view_status_of_cluster_action </a> , <a href="#view_status_of_node_action"> view_status_of_node_action </a> </td> </tr> <tr> <td> <a name="db-member-role"> </a> db_member </td> <td> <a href="#create_bdb"> create_bdb </a> , <a href="#create_crdb"> create_crdb </a> , <a href="#delete_bdb"> delete_bdb </a> , <a href="#delete_crdb"> delete_crdb </a> , <a href="#edit_bdb_module"> edit_bdb_module </a> , <a href="#failover_shard"> failover_shard </a> , <a href="#flush_crdb"> flush_crdb </a> , <a href="#migrate_shard"> migrate_shard </a> , <a href="#purge_instance"> purge_instance </a> , <a href="#reset_bdb_current_backup_status"> reset_bdb_current_backup_status </a> , <a href="#reset_bdb_current_export_status"> reset_bdb_current_export_status </a> , <a href="#reset_bdb_current_import_status"> reset_bdb_current_import_status </a> , <a href="#start_bdb_export"> start_bdb_export </a> , <a href="#start_bdb_import"> start_bdb_import </a> , <a href="#start_bdb_recovery"> start_bdb_recovery </a> , <a href="#update_bdb"> update_bdb </a> , <a href="#update_bdb_alerts"> update_bdb_alerts </a> , <a href="#update_bdb_with_action"> update_bdb_with_action </a> , <a href="#update_crdb"> update_crdb </a> , <a href="#view_all_bdb_stats"> view_all_bdb_stats </a> , <a href="#view_all_bdbs_alerts"> view_all_bdbs_alerts </a> , <a href="#view_all_bdbs_info"> view_all_bdbs_info </a> , <a href="#view_all_nodes_alerts"> view_all_nodes_alerts </a> , <a href="#view_all_nodes_checks"> view_all_nodes_checks </a> , <a href="#view_all_nodes_info"> view_all_nodes_info </a> , <a href="#view_all_nodes_stats"> view_all_nodes_stats </a> , <a href="#view_all_proxies_info"> view_all_proxies_info </a> , <a href="#view_all_redis_acls_info"> view_all_redis_acls_info </a> , <a href="#view_all_roles_info"> view_all_roles_info </a> , <a href="#view_all_shard_stats"> view_all_shard_stats </a> , <a href="#view_bdb_alerts"> view_bdb_alerts </a> , <a href="#view_bdb_info"> view_bdb_info </a> , <a href="#view_bdb_recovery_plan"> view_bdb_recovery_plan </a> , <a href="#view_bdb_stats"> view_bdb_stats </a> , <a href="#view_cluster_alerts"> view_cluster_alerts </a> , <a href="#view_cluster_info"> view_cluster_info </a> , <a href="#view_cluster_modules"> view_cluster_modules </a> , <a href="#view_cluster_stats"> view_cluster_stats </a> , <a href="#view_crdb"> view_crdb </a> , <a href="#view_crdb_list"> view_crdb_list </a> , <a href="#view_crdb_task"> view_crdb_task </a> , <a href="#view_crdb_task_list"> view_crdb_task_list </a> , <a href="#view_debugging_info"> view_debugging_info </a> , <a href="#view_endpoint_stats"> view_endpoint_stats </a> , <a href="#view_license"> view_license </a> , <a href="#view_logged_events"> view_logged_events </a> , <a href="#view_node_alerts"> view_node_alerts </a> , <a href="#view_node_check"> view_node_check </a> , <a href="#view_node_info"> view_node_info </a> , <a href="#view_node_stats"> view_node_stats </a> , <a href="#view_proxy_info"> view_proxy_info </a> , <a href="#view_redis_acl_info"> view_redis_acl_info </a> , <a href="#view_redis_pass"> view_redis_pass </a> , <a href="#view_role_info"> view_role_info </a> , <a href="#view_shard_stats"> view_shard_stats </a> , <a href="#view_status_of_all_node_actions"> view_status_of_all_node_actions </a> , <a href="#view_status_of_cluster_action"> view_status_of_cluster_action </a> , <a href="#view_status_of_node_action"> view_status_of_node_action </a> </td> </tr> <tr> <td> <a name="db-viewer-role"> </a> db_viewer </td> <td> <a href="#view_all_bdb_stats"> view_all_bdb_stats </a> , <a href="#view_all_bdbs_alerts"> view_all_bdbs_alerts </a> , <a href="#view_all_bdbs_info"> view_all_bdbs_info </a> , <a href="#view_all_nodes_alerts"> view_all_nodes_alerts </a> , <a href="#view_all_nodes_checks"> view_all_nodes_checks </a> , <a href="#view_all_nodes_info"> view_all_nodes_info </a> , <a href="#view_all_nodes_stats"> view_all_nodes_stats </a> , <a href="#view_all_proxies_info"> view_all_proxies_info </a> , <a href="#view_all_redis_acls_info"> view_all_redis_acls_info </a> , <a href="#view_all_roles_info"> view_all_roles_info </a> , <a href="#view_all_shard_stats"> view_all_shard_stats </a> , <a href="#view_bdb_alerts"> view_bdb_alerts </a> , <a href="#view_bdb_info"> view_bdb_info </a> , <a href="#view_bdb_recovery_plan"> view_bdb_recovery_plan </a> , <a href="#view_bdb_stats"> view_bdb_stats </a> , <a href="#view_cluster_alerts"> view_cluster_alerts </a> , <a href="#view_cluster_info"> view_cluster_info </a> , <a href="#view_cluster_modules"> view_cluster_modules </a> , <a href="#view_cluster_stats"> view_cluster_stats </a> , <a href="#view_crdb"> view_crdb </a> , <a href="#view_crdb_list"> view_crdb_list </a> , <a href="#view_crdb_task"> view_crdb_task </a> , <a href="#view_crdb_task_list"> view_crdb_task_list </a> , <a href="#view_endpoint_stats"> view_endpoint_stats </a> , <a href="#view_license"> view_license </a> , <a href="#view_node_alerts"> view_node_alerts </a> , <a href="#view_node_check"> view_node_check </a> , <a href="#view_node_info"> view_node_info </a> , <a href="#view_node_stats"> view_node_stats </a> , <a href="#view_proxy_info"> view_proxy_info </a> , <a href="#view_redis_acl_info"> view_redis_acl_info </a> , <a href="#view_role_info"> view_role_info </a> , <a href="#view_shard_stats"> view_shard_stats </a> , <a href="#view_status_of_all_node_actions"> view_status_of_all_node_actions </a> , <a href="#view_status_of_cluster_action"> view_status_of_cluster_action </a> , <a href="#view_status_of_node_action"> view_status_of_node_action </a> </td> </tr> <tr> <td> <a name="user-manager-role"> </a> user_manager </td> <td> <a href="#config_ldap"> config_ldap </a> , <a href="#create_ldap_mapping"> create_ldap_mapping </a> , <a href="#create_new_user"> create_new_user </a> , <a href="#create_role"> create_role </a> , <a href="#create_redis_acl"> create_redis_acl </a> , <a href="#delete_ldap_mapping"> delete_ldap_mapping </a> , <a href="#delete_redis_acl"> delete_redis_acl </a> , <a href="#delete_role"> delete_role </a> , <a href="#delete_user"> delete_user </a> , <a href="#install_new_license"> install_new_license </a> , <a href="#update_ldap_mapping"> update_ldap_mapping </a> , <a href="#update_proxy"> update_proxy </a> , <a href="#update_role"> update_role </a> , <a href="#update_redis_acl"> update_redis_acl </a> , <a href="#update_user"> update_user </a> , <a href="#view_all_bdb_stats"> view_all_bdb_stats </a> , <a href="#view_all_bdbs_alerts"> view_all_bdbs_alerts </a> , <a href="#view_all_bdbs_info"> view_all_bdbs_info </a> , <a href="#view_all_ldap_mappings_info"> view_all_ldap_mappings_info </a> , <a href="view_all_nodes_alerts"> view_all_nodes_alerts </a> , <a href="#view_all_nodes_checks"> view_all_nodes_checks </a> , <a href="#view_all_nodes_info"> view_all_nodes_info </a> , <a href="#view_all_nodes_stats"> view_all_nodes_stats </a> , <a href="#view_all_proxies_info"> view_all_proxies_info </a> , <a href="#view_all_redis_acls_info"> view_all_redis_acls_info </a> , <a href="#view_all_roles_info"> view_all_roles_info </a> , <a href="#view_all_shard_stats"> view_all_shard_stats </a> , <a href="#view_all_users_info"> view_all_users_info </a> , <a href="#view_bdb_alerts"> view_bdb_alerts </a> , <a href="#view_bdb_info"> view_bdb_info </a> , <a href="#view_bdb_stats"> view_bdb_stats </a> , <a href="#view_cluster_alerts"> view_cluster_alerts </a> , <a href="#view_cluster_info"> view_cluster_info </a> , <a href="#view_cluster_keys"> view_cluster_keys </a> , <a href="#view_cluster_modules"> view_cluster_modules </a> , <a href="#view_cluster_stats"> view_cluster_stats </a> , <a href="#view_crdb"> view_crdb </a> , <a href="#view_crdb_list"> view_crdb_list </a> , <a href="#view_crdb_task"> view_crdb_task </a> , <a href="#view_crdb_task_list"> view_crdb_task_list </a> , <a href="#view_endpoint_stats"> view_endpoint_stats </a> , <a href="#view_ldap_config"> view_ldap_config </a> , <a href="#view_ldap_mapping_info"> view_ldap_mapping_info </a> , <a href="#view_license"> view_license </a> , <a href="#view_logged_events"> view_logged_events </a> , <a href="#view_node_alerts"> view_node_alerts </a> , <a href="#view_node_check"> view_node_check </a> , <a href="#view_node_info"> view_node_info </a> , <a href="#view_node_stats"> view_node_stats </a> , <a href="#view_proxy_info"> view_proxy_info </a> , <a href="#view_redis_acl_info"> view_redis_acl_info </a> , <a href="#view_redis_pass"> view_redis_pass </a> , <a href="#view_role_info"> view_role_info </a> , <a href="#view_shard_stats"> view_shard_stats </a> , <a href="#view_status_of_all_node_actions"> view_status_of_all_node_actions </a> , <a href="#view_status_of_cluster_action"> view_status_of_cluster_action </a> , <a href="#view_status_of_node_action"> view_status_of_node_action </a> , <a href="#view_user_info"> view_user_info </a> </td> </tr> <tr> <td> </td> <td> </td> </tr> </tbody> </table> <h2 id="roles-list-per-permission"> Roles list per permission </h2> <table> <thead> <tr> <th> Permission </th> <th> Roles </th> </tr> </thead> <tbody> <tr> <td> <a name="add_cluster_module"> </a> add_cluster_module </td> <td> admin </td> </tr> <tr> <td> <a name="cancel_cluster_action"> </a> cancel_cluster_action </td> <td> admin </td> </tr> <tr> <td> <a name="cancel_node_action"> </a> cancel_node_action </td> <td> admin </td> </tr> <tr> <td> <a name="config_ldap"> </a> config_ldap </td> <td> admin <br/> user_manager </td> </tr> <tr> <td> <a name="config_ocsp"> </a> config_ocsp </td> <td> admin </td> </tr> <tr> <td> <a name="create_bdb"> </a> create_bdb </td> <td> admin <br/> cluster_member <br/> db_member </td> </tr> <tr> <td> <a name="create_crdb"> </a> create_crdb </td> <td> admin <br/> cluster_member <br/> db_member </td> </tr> <tr> <td> <a name="create_ldap_mapping"> </a> create_ldap_mapping </td> <td> admin <br/> user_manager </td> </tr> <tr> <td> <a name="create_new_user"> </a> create_new_user </td> <td> admin <br/> user_manager </td> </tr> <tr> <td> <a name="create_redis_acl"> </a> create_redis_acl </td> <td> admin <br/> user_manager </td> </tr> <tr> <td> <a name="create_role"> </a> create_role </td> <td> admin <br/> user_manager </td> </tr> <tr> <td> <a name="delete_bdb"> </a> delete_bdb </td> <td> admin <br/> cluster_member <br/> db_member </td> </tr> <tr> <td> <a name="delete_cluster_module"> </a> delete_cluster_module </td> <td> admin </td> </tr> <tr> <td> <a name="delete_crdb"> </a> delete_crdb </td> <td> admin <br/> cluster_member <br/> db_member </td> </tr> <tr> <td> <a name="delete_ldap_mapping"> </a> delete_ldap_mapping </td> <td> admin <br/> user_manager </td> </tr> <tr> <td> <a name="delete_redis_acl"> </a> delete_redis_acl </td> <td> admin <br/> user_manager </td> </tr> <tr> <td> <a name="delete_role"> </a> delete_role </td> <td> admin <br/> user_manager </td> </tr> <tr> <td> <a name="delete_user"> </a> delete_user </td> <td> admin <br/> user_manager </td> </tr> <tr> <td> <a name="edit_bdb_module"> </a> edit_bdb_module </td> <td> admin <br/> cluster_member <br/> db_member </td> </tr> <tr> <td> <a name="failover_shard"> </a> failover_shard </td> <td> admin <br/> cluster_member <br/> db_member </td> </tr> <tr> <td> <a name="flush_crdb"> </a> flush_crdb </td> <td> admin <br/> cluster_member <br/> db_member </td> </tr> <tr> <td> <a name="install_new_license"> </a> install_new_license </td> <td> admin <br/> user_manager </td> </tr> <tr> <td> <a name="migrate_shard"> </a> migrate_shard </td> <td> admin <br/> cluster_member <br/> db_member </td> </tr> <tr> <td> <a name="purge_instance"> </a> purge_instance </td> <td> admin <br/> cluster_member <br/> db_member </td> </tr> <tr> <td> <a name="reset_bdb_current_backup_status"> </a> reset_bdb_current_backup_status </td> <td> admin <br/> cluster_member <br/> db_member </td> </tr> <tr> <td> <a name="reset_bdb_current_export_status"> </a> reset_bdb_current_export_status </td> <td> admin <br/> cluster_member <br/> db_member </td> </tr> <tr> <td> <a name="reset_bdb_current_import_status"> </a> reset_bdb_current_import_status </td> <td> admin <br/> cluster_member <br/> db_member </td> </tr> <tr> <td> <a name="start_bdb_export"> </a> start_bdb_export </td> <td> admin <br/> cluster_member <br/> db_member </td> </tr> <tr> <td> <a name="start_bdb_import"> </a> start_bdb_import </td> <td> admin <br/> cluster_member <br/> db_member </td> </tr> <tr> <td> <a name="start_bdb_recovery"> </a> start_bdb_recovery </td> <td> admin <br/> cluster_member <br/> db_member </td> </tr> <tr> <td> <a name="start_cluster_action"> </a> start_cluster_action </td> <td> admin </td> </tr> <tr> <td> <a name="start_node_action"> </a> start_node_action </td> <td> admin </td> </tr> <tr> <td> <a name="test_ocsp_status"> </a> test_ocsp_status </td> <td> admin </td> </tr> <tr> <td> <a name="update_bdb"> </a> update_bdb </td> <td> admin <br/> cluster_member <br/> db_member </td> </tr> <tr> <td> <a name="update_bdb_alerts"> </a> update_bdb_alerts </td> <td> admin <br/> cluster_member <br/> db_member </td> </tr> <tr> <td> <a name="update_bdb_with_action"> </a> update_bdb_with_action </td> <td> admin <br/> cluster_member <br/> db_member </td> </tr> <tr> <td> <a name="update_cluster"> </a> update_cluster </td> <td> admin </td> </tr> <tr> <td> <a name="update_crdb"> </a> update_crdb </td> <td> admin <br/> cluster_member <br/> db_member </td> </tr> <tr> <td> <a name="update_ldap_mapping"> </a> update_ldap_mapping </td> <td> admin <br/> user_manager </td> </tr> <tr> <td> <a name="update_node"> </a> update_node </td> <td> admin </td> </tr> <tr> <td> <a name="update_proxy"> </a> update_proxy </td> <td> admin <br/> user_manager </td> </tr> <tr> <td> <a name="update_redis_acl"> </a> update_redis_acl </td> <td> admin <br/> user_manager </td> </tr> <tr> <td> <a name="update_role"> </a> update_role </td> <td> admin <br/> user_manager </td> </tr> <tr> <td> <a name="update_user"> </a> update_user </td> <td> admin <br/> user_manager </td> </tr> <tr> <td> <a name="view_all_bdb_stats"> </a> view_all_bdb_stats </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_all_bdbs_alerts"> </a> view_all_bdbs_alerts </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_all_bdbs_info"> </a> view_all_bdbs_info </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_all_ldap_mappings_info"> </a> view_all_ldap_mappings_info </td> <td> admin <br/> user_manager </td> </tr> <tr> <td> <a name="view_all_nodes_alerts"> </a> view_all_nodes_alerts </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_all_nodes_checks"> </a> view_all_nodes_checks </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_all_nodes_info"> </a> view_all_nodes_info </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_all_nodes_stats"> </a> view_all_nodes_stats </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_all_proxies_info"> </a> view_all_proxies_info </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_all_redis_acls_info"> </a> view_all_redis_acls_info </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_all_roles_info"> </a> view_all_roles_info </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_all_shard_stats"> </a> view_all_shard_stats </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_all_users_info"> </a> view_all_users_info </td> <td> admin <br/> user_manager </td> </tr> <tr> <td> <a name="view_bdb_alerts"> </a> view_bdb_alerts </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_bdb_info"> </a> view_bdb_info </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_bdb_recovery_plan"> </a> view_bdb_recovery_plan </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_bdb_stats"> </a> view_bdb_stats </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_cluster_alerts"> </a> view_cluster_alerts </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_cluster_info"> </a> view_cluster_info </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_cluster_keys"> </a> view_cluster_keys </td> <td> admin <br/> cluster_member <br/> user_manager </td> </tr> <tr> <td> <a name="view_cluster_modules"> </a> view_cluster_modules </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_cluster_stats"> </a> view_cluster_stats </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_crdb"> </a> view_crdb </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_crdb_list"> </a> view_crdb_list </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_crdb_task"> </a> view_crdb_task </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_crdb_task_list"> </a> view_crdb_task_list </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_debugging_info"> </a> view_debugging_info </td> <td> admin <br/> cluster_member <br/> db_member <br/> user_manager </td> </tr> <tr> <td> <a name="view_endpoint_stats"> </a> view_endpoint_stats </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_ldap_config"> </a> view_ldap_config </td> <td> admin <br/> user_manager </td> </tr> <tr> <td> <a name="view_ldap_mapping_info"> </a> view_ldap_mapping_info </td> <td> admin <br/> user_manager </td> </tr> <tr> <td> <a name="view_license"> </a> view_license </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_logged_events"> </a> view_logged_events </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> user_manager </td> </tr> <tr> <td> <a name="view_node_alerts"> </a> view_node_alerts </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_node_check"> </a> view_node_check </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_node_info"> </a> view_node_info </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_node_stats"> </a> view_node_stats </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_ocsp_config"> </a> view_ocsp_config </td> <td> admin </td> </tr> <tr> <td> <a name="view_ocsp_status"> </a> view_ocsp_status </td> <td> admin </td> </tr> <tr> <td> <a name="view_proxy_info"> </a> view_proxy_info </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_redis_acl_info"> </a> view_redis_acl_info </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_redis_pass"> </a> view_redis_pass </td> <td> admin <br/> cluster_member <br/> db_member <br/> user_manager </td> </tr> <tr> <td> <a name="view_role_info"> </a> view_role_info </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_shard_stats"> </a> view_shard_stats </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_status_of_all_node_actions"> </a> view_status_of_all_node_actions </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_status_of_cluster_action"> </a> view_status_of_cluster_action </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_status_of_node_action"> </a> view_status_of_node_action </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer <br/> user_manager </td> </tr> <tr> <td> <a name="view_user_info"> </a> view_user_info </td> <td> admin <br/> user_manager </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/rest-api/permissions/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/zincrby/.html
<section class="prose w-full py-12"> <h1 class="command-name"> ZINCRBY </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">ZINCRBY key increment member</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 1.2.0 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(log(N)) where N is the number of elements in the sorted set. </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @write </code> <span class="mr-1 last:hidden"> , </span> <code> @sortedset </code> <span class="mr-1 last:hidden"> , </span> <code> @fast </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> Increments the score of <code> member </code> in the sorted set stored at <code> key </code> by <code> increment </code> . If <code> member </code> does not exist in the sorted set, it is added with <code> increment </code> as its score (as if its previous score was <code> 0.0 </code> ). If <code> key </code> does not exist, a new sorted set with the specified <code> member </code> as its sole member is created. </p> <p> An error is returned when <code> key </code> exists but does not hold a sorted set. </p> <p> The <code> score </code> value should be the string representation of a numeric value, and accepts double precision floating point numbers. It is possible to provide a negative value to decrement the score. </p> <h2 id="examples"> Examples </h2> <div class="bg-slate-900 border-b border-slate-700 rounded-t-xl px-4 py-3 w-full flex"> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10Z"> </path> </svg> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M10 2.5L18.6603 17.5L1.33975 17.5L10 2.5Z"> </path> </svg> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M10 2.5L12.0776 7.9322L17.886 8.22949L13.3617 11.8841L14.8738 17.5L10 14.3264L5.1262 17.5L6.63834 11.8841L2.11403 8.22949L7.92238 7.9322L10 2.5Z"> </path> </svg> </div> <form class="redis-cli overflow-y-auto max-h-80"> <pre tabindex="0">redis&gt; ZADD myzset 1 "one" (integer) 1 redis&gt; ZADD myzset 2 "two" (integer) 1 redis&gt; ZINCRBY myzset 2 "one" "3" redis&gt; ZRANGE myzset 0 -1 WITHSCORES 1) "two" 2) "2" 3) "one" 4) "3" </pre> <div class="prompt" style=""> <span> redis&gt; </span> <input autocomplete="off" name="prompt" spellcheck="false" type="text"/> </div> </form> <h2 id="resp2-reply"> RESP2 Reply </h2> <a href="../../develop/reference/protocol-spec#bulk-strings"> Bulk string reply </a> : the new score of <em> member </em> as a double precision floating point number. <h2 id="resp3-reply"> RESP3 Reply </h2> <a href="../../develop/reference/protocol-spec#doubles"> Double reply </a> : the new score of <em> member </em> . <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/zincrby/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/develop/data-types/json/indexing_json/.html
<section class="prose w-full py-12"> <h1> Index/Search JSON documents </h1> <p class="text-lg -mt-5 mb-10"> Combine Redis JSON and the Redis Query Engine to index and search JSON documents </p> <p> In addition to storing JSON documents, you can also index them using the <a href="/docs/latest/develop/interact/search-and-query/"> Redis Query Engine </a> feature. This enables full-text search capabilities and document retrieval based on their content. </p> <p> To use these features, you must install two modules: RedisJSON and RediSearch. <a href="/docs/latest/operate/oss_and_stack/"> Redis Stack </a> automatically includes both modules. </p> <p> See the <a href="/docs/latest/develop/interact/search-and-query/indexing/"> tutorial </a> to learn how to search and query your JSON. </p> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/data-types/json/indexing_json/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisgraph/redisgraph-2.10-release-notes.html
<section class="prose w-full py-12 max-w-none"> <h1> RedisGraph 2.10 release notes </h1> <p class="text-lg -mt-5 mb-10"> Introduces new path algorithms, additional expressivity (constructs and functions), performance improvements, and bug fixes. </p> <h2 id="requirements"> Requirements </h2> <p> RedisGraph v2.10.15 requires: </p> <ul> <li> Minimum Redis compatibility version (database): 6.2.0 </li> <li> Minimum Redis Enterprise Software version (cluster): 6.2.8 </li> </ul> <h2 id="v21015-september-2023"> v2.10.15 (September 2023) </h2> <p> This is a maintenance release for RedisGraph 2.10. </p> <p> Update urgency: <code> MODERATE </code> : Program an upgrade of the server, but it's not urgent. </p> <p> Details: </p> <ul> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/3172"> #3172 </a> Crash on certain write queries (MOD-5645) </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/3179"> #3179 </a> High CPU on idle </li> </ul> </li> <li> <p> Improvements: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/3184"> #3184 </a> Revert breaking change introduced in 2.10: <code> toString </code> supports list argument again </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/3185"> #3185 </a> Don’t write AUX field in the RDB file when there are no graphs in the keyspace </li> </ul> </li> </ul> <h2 id="v21012-july-2023"> v2.10.12 (July 2023) </h2> <p> This is a maintenance release for RedisGraph 2.10. </p> <p> Update urgency: <code> MODERATE </code> : Program an upgrade of the server, but it's not urgent. </p> <p> Details: </p> <ul> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/3129"> #3129 </a> Crash on certain queries ( <code> INDEX SCAN </code> followed by <code> DEL </code> followed by <code> SET </code> ) (MOD-5430) </li> </ul> </li> </ul> <h2 id="v21011-june-2023"> v2.10.11 (June 2023) </h2> <p> This is a maintenance release for RedisGraph 2.10. </p> <p> Update urgency: <code> MODERATE </code> : Program an upgrade of the server, but it's not urgent. </p> <p> Details: </p> <ul> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/3096"> #3096 </a> Potential crash on query timeout (MOD-5202) </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/3042"> #3042 </a> , <a href="https://github.com/RedisGraph/RedisGraph/issues/3052"> #3052 </a> Potential crashes due to false assertions </li> </ul> </li> </ul> <h2 id="v21010-april-2023"> v2.10.10 (April 2023) </h2> <p> This is a maintenance release for RedisGraph 2.10. </p> <p> Update urgency: <code> MODERATE </code> : Program an upgrade of the server, but it's not urgent. </p> <p> Details: </p> <ul> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/3038"> #3038 </a> Potential crash when a query with a <code> UNION </code> clause sets or modifies an indexed property </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2631"> #2631 </a> , <a href="https://github.com/RedisGraph/RedisGraph/issues/2968"> #2968 </a> Potential crash on certain <code> MATCH </code> clauses where label filters are used (MOD-5093) </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2957"> #2957 </a> Label filters in expressions such as <code> WITH n MATCH (n:X) </code> are ignored </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2931"> #2931 </a> , <a href="https://github.com/RedisGraph/RedisGraph/issues/3027"> #3027 </a> Wrong overflow error message </li> </ul> </li> </ul> <h2 id="v2109-march-2023"> v2.10.9 (March 2023) </h2> <p> This is a maintenance release for RedisGraph 2.10. </p> <p> Update urgency: <code> HIGH </code> : There is a critical bug that may affect a subset of users. Upgrade! </p> <p> Details: </p> <ul> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2880"> #2880 </a> Potential crash when using <code> WITH * </code> expressions </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2917"> #2917 </a> Potential crash when using <code> CASE </code> expressions (MOD-4873) </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2836"> #2836 </a> Potential crash on <code> *0 </code> variable-length path (MOD-4817) </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2916"> #2916 </a> Potential crash when executing concurrent queries that utilize full-text indices (MOD-4818) </li> </ul> </li> </ul> <h2 id="v2108-february-2023"> v2.10.8 (February 2023) </h2> <p> This is a maintenance release for RedisGraph 2.10. </p> <p> Update urgency: <code> HIGH </code> : There is a critical bug that may affect a subset of users. Upgrade! </p> <p> Details: </p> <ul> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2777"> #2777 </a> , <a href="https://github.com/RedisGraph/RedisGraph/issues/2841"> #2841 </a> Potential crash when sending queries from multiple connections and timeout is not 0 </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2844"> #2844 </a> Potential partial results when same parametrized query is running from multiple connections </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2739"> #2739 </a> , <a href="https://github.com/RedisGraph/RedisGraph/issues/2774"> #2774 </a> Paths with exact variable length &gt;1 are not matched </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2794"> #2794 </a> <code> toInteger </code> and <code> toIntegerOrNull </code> don't convert Booleans </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2798"> #2798 </a> <code> right </code> and <code> left </code> should reply with an error when <code> length </code> is null </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2809"> #2809 </a> <code> TIMEOUT_MAX </code> configuration parameter is not enforced when <code> TIMEOUT_DEFAULT </code> is 0 </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2780"> #2780 </a> <code> indegree </code> and <code> outdegree </code> - relationships are counted more than once when same relationship type is supplied more than once </li> </ul> </li> <li> <p> Improvements: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2790"> #2790 </a> Improved performance by disabling SuiteSparse:GraphBLAS' global free pool </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2758"> #2758 </a> Improved edge deletion performance </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2781"> #2781 </a> <code> indegree </code> and <code> outdegree </code> now also accept an argument which is a list of labels </li> </ul> </li> </ul> <h2 id="v2105-december-2022"> v2.10.5 (December 2022) </h2> <p> This is a maintenance release for RedisGraph 2.10. </p> <p> Update urgency: <code> HIGH </code> : There is a critical bug that may affect a subset of users. Upgrade! </p> <p> Details: </p> <ul> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2754"> #2754 </a> Partial sync may hang (MOD-4594) </li> </ul> </li> <li> <p> Improvements: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2757"> #2757 </a> Improved performance of <code> indegree </code> and <code> outdegree </code> </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2681"> #2681 </a> Fixed some error messages </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2740"> #2740 </a> Don’t show partial results for timed-out <code> GRAPH.PROFILE </code> </li> </ul> </li> </ul> <h2 id="v210-ga-v2104-november-2022"> v2.10 GA (v2.10.4) (November 2022) </h2> <p> This is the General Availability release of RedisGraph 2.10. </p> <h3 id="highlights"> Highlights </h3> <p> RedisGraph 2.10 introduces new path algorithms, additional expressivity (constructs and functions), performance improvements, and bug fixes. </p> <h4 id="whats-new-in-210"> What's new in 2.10 </h4> <ul> <li> New pathfinding algorithms: <ul> <li> The <code> algo.SPpaths </code> procedure yields one, <em> n </em> , or all minimal-weight, optionally bounded-cost, optionally bounded-length paths between a given pair of nodes. </li> <li> The <code> algo.SSpaths </code> procedure yields one, <em> n </em> , or all minimal-weight, optionally bounded-cost, optionally bounded-length paths from a given node. </li> </ul> </li> <li> Introduce <code> SET </code> for adding node labels and <code> REMOVE </code> for removing node labels, node properties, and edge properties. </li> <li> Support deleting paths with <code> DELETE </code> . </li> <li> Introduce 29 functions: <code> toBoolean </code> , <code> toBooleanOrNull </code> , <code> toFloatOrNull </code> , <code> toIntegerOrNull </code> , <code> toStringOrNull </code> , <code> toBooleanList </code> , <code> toFloatList </code> , <code> toIntegerList </code> , <code> toStringList </code> , <code> properties </code> , <code> split </code> , <code> last </code> , <code> isEmpty </code> , <code> e </code> , <code> exp </code> , <code> log </code> , <code> log10 </code> , <code> sin </code> , <code> cos </code> , <code> tan </code> , <code> cot </code> , <code> asin </code> , <code> acos </code> , <code> atan </code> , <code> atan2 </code> , <code> degrees </code> , <code> radians </code> , <code> pi </code> , and <code> haversin </code> . </li> <li> Graph slow log can be reset with <code> GRAPH.SLOWLOG g RESET </code> . </li> <li> Queries are now atomic ( <em> Atomicity </em> is the guarantee that each query either succeeds or fails with no side effects). Whenever a failure occurs, the query effect is rolled back from an undo log. </li> </ul> <h3 id="details"> Details </h3> <ul> <li> <p> Bug fixes (since 2.10-RC1): </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2695"> #2695 </a> Potential crash on certain write queries (MOD-4286, MOD-4545) </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2724"> #2724 </a> Potential crash when setting property values based on nonexistent properties </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2460"> #2460 </a> , <a href="https://github.com/RedisGraph/RedisGraph/issues/2637"> #2637 </a> , <a href="https://github.com/RedisGraph/RedisGraph/issues/2680"> #2680 </a> Crash on invalid queries </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2672"> #2672 </a> Wrong matching result on multiple labels </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2643"> #2643 </a> Duplicate reports when matching relationship type <code> :R|R </code> </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2687"> #2687 </a> , <a href="https://github.com/RedisGraph/RedisGraph/issues/2414"> #2414 </a> Error when <code> UNWIND </code> ing relationships </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2636"> #2636 </a> <code> MERGE </code> ... <code> ON </code> ... - cannot remove property by setting it to null </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2710"> #2710 </a> Undo log fix </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2435"> #2435 </a> Incorrect result when comparing a value to NaN </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2497"> #2497 </a> Incorrect result when comparing a value to null </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2676"> #2676 </a> <code> sqrt </code> , <code> log </code> , <code> log10 </code> - incorrect result for negative values </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2213"> #2213 </a> Division and Modulo by zero - wrong behavior </li> </ul> </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisgraph/redisgraph-2.10-release-notes/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisgraph/redisgraph-2.8-release-notes.html
<section class="prose w-full py-12 max-w-none"> <h1> RedisGraph 2.8 release notes </h1> <p class="text-lg -mt-5 mb-10"> Introduces multi-labeled nodes, indexes over relationship properties, and additional expressivity (Cypher construct, functions, and operators). Major performance enhancements. Many bug fixes. </p> <h2 id="requirements"> Requirements </h2> <p> RedisGraph v2.8.26 requires: </p> <ul> <li> Minimum Redis compatibility version (database): 6.2.0 </li> <li> Minimum Redis Enterprise Software version (cluster): 6.2.8 </li> </ul> <h2 id="v2826-march-2023"> v2.8.26 (March 2023) </h2> <p> This is a maintenance release for RedisGraph 2.8. </p> <p> Update urgency: <code> HIGH </code> : There is a critical bug that may affect a subset of users. Upgrade! </p> <p> Details: </p> <ul> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2880"> #2880 </a> Potential crash when using WITH * expressions </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2917"> #2917 </a> Potential crash when using CASE expressions (MOD-4873) </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2836"> #2836 </a> Potential crash on *0 variable-length path (MOD-4817) </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2916"> #2916 </a> Potential crash when executing concurrent queries that utilize full-text indices (MOD-4818) </li> </ul> </li> </ul> <h2 id="v2825-february-2023"> v2.8.25 (February 2023) </h2> <p> This is a maintenance release for RedisGraph 2.8. </p> <p> Update urgency: <code> MODERATE </code> : Program an upgrade of the server, but it's not urgent. </p> <p> Details: </p> <ul> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2890"> #2890 </a> Potential wrong results on variable-length path </li> </ul> </li> </ul> <h2 id="v2824-february-2023"> v2.8.24 (February 2023) </h2> <p> This is a maintenance release for RedisGraph 2.8. </p> <p> Update urgency: <code> HIGH </code> : There is a critical bug that may affect a subset of users. Upgrade! </p> <p> Details: </p> <ul> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2777"> #2777 </a> , <a href="https://github.com/RedisGraph/RedisGraph/issues/2841"> #2841 </a> Potential crash when sending queries from multiple connections and timeout is not 0 </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2844"> #2844 </a> Potential partial results when same parametrized query is running from multiple connections </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2739"> #2739 </a> , <a href="https://github.com/RedisGraph/RedisGraph/issues/2774"> #2774 </a> Paths with exact variable length &gt;1 are not matched </li> </ul> </li> <li> <p> Improvements: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2758"> #2758 </a> Improved edge deletion performance </li> </ul> </li> </ul> <h2 id="v2821-january-2023"> v2.8.21 (January 2023) </h2> <p> This is a maintenance release for RedisGraph 2.8. </p> <p> Update urgency: <code> HIGH </code> : There is a critical bug that may affect a subset of users. Upgrade! </p> <p> Details: </p> <ul> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2754"> #2754 </a> Partial sync may hang (MOD-4594) </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2695"> #2695 </a> Potential crash on certain write queries (MOD-4286, MOD-4545) </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2637"> #2637 </a> , <a href="https://github.com/RedisGraph/RedisGraph/issues/2460"> #2460 </a> , <a href="https://github.com/RedisGraph/RedisGraph/issues/2680"> #2680 </a> Crash on invalid queries </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2484"> #2484 </a> Indexes can be created on invalid property names </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2672"> #2672 </a> Wrong matching result on multiple labels </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2643"> #2643 </a> Duplicate reports when matching relationship type <code> :R|R </code> </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2687"> #2687 </a> , <a href="https://github.com/RedisGraph/RedisGraph/issues/2414"> #2414 </a> Error when <code> UNWIND </code> ing relationships </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2635"> #2635 </a> Cannot <code> UNWIND </code> an expression that is not a list </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2636"> #2636 </a> <code> MERGE </code> ... <code> ON </code> ... - cannot remove a property by setting it to null </li> </ul> </li> <li> <p> Improvements: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2790"> #2790 </a> Improved performance by disabling SuiteSparse:GraphBLAS' global free pool </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2757"> #2757 </a> Improved performance of <code> indegree </code> and <code> outdegree </code> </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2740"> #2740 </a> Don’t show partial results for timed out <code> GRAPH.PROFILE </code> </li> </ul> </li> </ul> <h2 id="v2820-september-2022"> v2.8.20 (September 2022) </h2> <p> This is a maintenance release for RedisGraph 2.8. </p> <p> Update urgency: <code> MODERATE </code> : Program an upgrade of the server, but it's not urgent. </p> <p> Details: </p> <ul> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2591"> #2591 </a> Potential crash trying to utilize a nonexistent index </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2558"> #2558 </a> Multi-relationship properties created before index creation are not indexed </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2571"> #2571 </a> <code> min </code> and <code> max </code> return wrong results when the argument is an array </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2587"> #2587 </a> Some queries generate a "forced unlocking commit flow" warning </li> </ul> </li> <li> <p> Improvements: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2533"> #2533 </a> Graph slow log can be reset with <code> GRAPH.SLOWLOG g RESET </code> </li> </ul> </li> </ul> <h2 id="v2819-august-2022"> v2.8.19 (August 2022) </h2> <p> This is a maintenance release for RedisGraph 2.8. </p> <p> Update urgency: <code> MODERATE </code> : Program an upgrade of the server, but it's not urgent. </p> <p> Details: </p> <ul> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2517"> #2517 </a> Crash on invalid <code> REDUCE </code> queries </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2525"> #2525 </a> <code> toJSON </code> - node labels are not separated with a comma ( <code> , </code> ) </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2467"> #2467 </a> Possibly wrong results when using a variable named <code> anon_N </code> </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2522"> #2522 </a> Deleting an edge index leaves traces </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2477"> #2477 </a> Cannot extract the latitude or the longitude of a point </li> </ul> </li> <li> <p> Improvements: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2519"> #2519 </a> When a query is cached and then a relevant index is created, recalculate the execution plan </li> </ul> </li> </ul> <h2 id="v2817-july-2022"> v2.8.17 (July 2022) </h2> <p> This is a maintenance release for RedisGraph 2.8. </p> <p> Update urgency: <code> HIGH </code> : There is a critical bug that may affect a subset of users. Upgrade! </p> <p> Details: </p> <ul> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2499"> #2499 </a> Potential crash with concurrent connections due to missing lock - additional fixes </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2424"> #2424 </a> Potential crash when using <code> ORDER BY </code> </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2491"> #2491 </a> Whitespaces between <code> MATCH </code> terms can render the query invalid </li> </ul> </li> </ul> <h2 id="v2816-july-2022"> v2.8.16 (July 2022) </h2> <p> This is a maintenance release for RedisGraph 2.8. </p> <p> Update urgency: <code> HIGH </code> : There is a critical bug that may affect a subset of users. Upgrade! </p> <p> Details: </p> <ul> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2478"> #2478 </a> Potential crash with concurrent connections due to missing lock </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2370"> #2370 </a> Potential crash / wrong results / warning messages when using edge indexes </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2473"> #2473 </a> Crash on invalid <code> distance() </code> query with index </li> </ul> </li> </ul> <h2 id="v2815-june-2022"> v2.8.15 (June 2022) </h2> <p> This is a maintenance release for RedisGraph 2.8. </p> <p> Update urgency: <code> HIGH </code> : There is a critical bug that may affect a subset of users. Upgrade! </p> <p> Details: </p> <ul> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2241"> #2241 </a> Possible crash on queries with <code> MERGE </code> operation in a Cartesian product (MOD-3500) </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2394"> #2394 </a> Possible crash when freeing an index immediately after its creation </li> </ul> </li> </ul> <h2 id="v2814-june-2022"> v2.8.14 (June 2022) </h2> <p> This is a maintenance release for RedisGraph 2.8. </p> <p> Update urgency: <code> HIGH </code> : There is a critical bug that may affect a subset of users. Upgrade! </p> <p> Details: </p> <ul> <li> <p> Features: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2403"> #2403 </a> Introduce <code> toFloat </code> function </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2365"> #2365 </a> Commands that don't execute on the main thread now also appear in <a href="/docs/latest/commands/slowlog/"> SLOWLOG </a> </li> </ul> </li> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2381"> #2381 </a> Rare data corruption on data encoding </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2393"> #2393 </a> , <a href="https://github.com/RedisGraph/RedisGraph/issues/2395"> #2395 </a> Crash when searching an index for a runtime-determined value </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2377"> #2377 </a> Crash on <code> INT_MIN % -1 </code> </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2390"> #2390 </a> Crash on distance filter </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2407"> #2407 </a> Crash on double to string </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2422"> #2422 </a> <code> toJSON </code> returned floating points cropped to 6 decimals </li> </ul> </li> </ul> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> New RDB version (v12). RDB files created with v2.8.14 or later are not backward compatible. </div> </div> <h2 id="v2813-may-2022"> v2.8.13 (May 2022) </h2> <p> This is a maintenance release for RedisGraph 2.8. </p> <p> Update urgency: <code> HIGH </code> : There is a critical bug that may affect a subset of users. Upgrade! </p> <p> Details: </p> <ul> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2351"> #2351 </a> Potential memory leak on query timeout </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2348"> #2348 </a> Crash when converting certain Cypher queries to RediSearch queries </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2331"> #2331 </a> Two memory leaks (one on failed RDB loading, one on certain invalid queries) </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2328"> #2328 </a> , <a href="https://github.com/RedisGraph/RedisGraph/issues/2306"> #2306 </a> , <a href="https://github.com/RedisGraph/RedisGraph/issues/2307"> #2307 </a> , <a href="https://github.com/RedisGraph/RedisGraph/issues/2326"> #2326 </a> Disallow redeclaration of variables; fixed false redeclaration errors </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2363"> #2363 </a> Nodes were sometimes created with more labels than those specified </li> </ul> </li> </ul> <h2 id="v2812-may-2022"> v2.8.12 (May 2022) </h2> <p> This is a maintenance release for RedisGraph 2.8. </p> <p> Update urgency: <code> HIGH </code> : There is a critical bug that may affect a subset of users. Upgrade! </p> <p> Details: </p> <ul> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2278"> #2278 </a> , <a href="https://github.com/RedisGraph/RedisGraph/pull/2301"> #2301 </a> Potential crash on bulk update </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2262"> #2262 </a> , <a href="https://github.com/RedisGraph/RedisGraph/issues/2271"> #2271 </a> , <a href="https://github.com/RedisGraph/RedisGraph/issues/2272"> #2272 </a> , <a href="https://github.com/RedisGraph/RedisGraph/issues/2273"> #2273 </a> , <a href="https://github.com/RedisGraph/RedisGraph/issues/2282"> #2282 </a> , <a href="https://github.com/RedisGraph/RedisGraph/issues/2288"> #2288 </a> , <a href="https://github.com/RedisGraph/RedisGraph/issues/2299"> #2299 </a> , <a href="https://github.com/RedisGraph/RedisGraph/issues/2312"> #2312 </a> , <a href="https://github.com/RedisGraph/RedisGraph/issues/2321"> #2321 </a> , <a href="https://github.com/RedisGraph/RedisGraph/issues/2325"> #2325 </a> , <a href="https://github.com/RedisGraph/RedisGraph/issues/2323"> #2323 </a> Potential crash on certain queries </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/1441"> #1441 </a> Query returns wrong result: projection before Cartesian product causes only one result to be returned </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2298"> #2298 </a> Query returns wrong result: wrong value when fetching a string property from a map </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2318"> #2318 </a> Memory leak </li> </ul> </li> </ul> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> Duplicate column names in a query are no longer valid. For example, the query <code> GRAPH.QUERY g "MATCH (e) RETURN e, e" </code> is not valid. If you need to return the same column twice, you can rewrite the query as <code> GRAPH.QUERY g "MATCH (e) RETURN e, e as e2" </code> . </div> </div> <h2 id="v2811-march-2022"> v2.8.11 (March 2022) </h2> <p> This is a maintenance release for RedisGraph 2.8. </p> <p> Update urgency: <code> HIGH </code> : There is a critical bug that may affect a subset of users. Upgrade! </p> <p> Details: </p> <ul> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2259"> #2259 </a> , <a href="https://github.com/RedisGraph/RedisGraph/pull/2258"> #2258 </a> Fix memory leak and potential crash on <a href="/docs/latest/operate/oss_and_stack/management/persistence/"> RDB </a> saving </li> </ul> </li> </ul> <h2 id="v2810-march-2022"> v2.8.10 (March 2022) </h2> <p> This is a maintenance release for RedisGraph 2.8. </p> <p> Update urgency: <code> HIGH </code> : There is a critical bug that may affect a subset of users. Upgrade! </p> <p> Details: </p> <ul> <li> <p> Features: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2245"> #2245 </a> Support graphs <a href="/docs/latest/develop/reference/eviction/"> eviction </a> </li> </ul> </li> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/1493"> #1493 </a> , <a href="https://github.com/RedisGraph/RedisGraph/pull/2240"> #2240 </a> Fixed crash on certain queries </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2229"> #2229 </a> , <a href="https://github.com/RedisGraph/RedisGraph/pull/2222"> #2222 </a> Fixed crash on certain queries </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2209"> #2209 </a> , <a href="https://github.com/RedisGraph/RedisGraph/pull/2228"> #2228 </a> Fixed crash on certain invalid <code> DELETE </code> queries </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2237"> #2237 </a> , <a href="https://github.com/RedisGraph/RedisGraph/pull/2242"> #2242 </a> Fixed crash on certain <code> PROFILE </code> queries </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2230"> #2230 </a> , <a href="https://github.com/RedisGraph/RedisGraph/pull/2232"> #2232 </a> Fixed wrong number of reported deleted relationships on certain queries </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2233"> #2233 </a> Certain valid queries were reported invalid </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2246"> #2246 </a> Fixed memory leaks </li> </ul> </li> <li> <p> Improvements: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2235"> #2235 </a> Improved <a href="/docs/latest/operate/oss_and_stack/management/persistence/"> RDB </a> loading performance </li> </ul> </li> </ul> <h2 id="v289-march-2022"> v2.8.9 (March 2022) </h2> <p> This is a maintenance release for RedisGraph 2.8. </p> <p> Update urgency: <code> MODERATE </code> : Program an upgrade of the server, but it's not urgent. </p> <p> Details: </p> <ul> <li> <p> Features: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2181"> #2181 </a> , <a href="https://github.com/RedisGraph/RedisGraph/pull/2182"> #2182 </a> Full support for ARM builds </li> </ul> </li> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2167"> #2167 </a> Fixed a potential crash: filter placement in <code> OPTIONAL </code> subtrees </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2176"> #2176 </a> Fixed a potential crash: invalid memory access in nested <code> DISTINCT </code> functions </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2217"> #2217 </a> Fixed a potential crash: memory access after free on <code> FLUSHALL </code> </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2207"> #2207 </a> Fixed memory leak when <code> MAX_QUEUED_QUERIES </code> is used </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2220"> #2220 </a> <code> WITH * WHERE </code> - the <code> WHERE </code> filters were ignored </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2151"> #2151 </a> Return correct results for aggregations with no inputs </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2163"> #2163 </a> Emit error correctly on multi-query inputs </li> </ul> </li> <li> <p> Improvements: </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2173"> #2173 </a> Improve performance of breadth-first search </li> </ul> </li> </ul> <h2 id="v28-ga-v288-february-2022"> v2.8 GA (v2.8.8) (February 2022) </h2> <p> This is the General Availability release of RedisGraph 2.8. </p> <h3 id="highlights"> Highlights </h3> <p> RedisGraph 2.8 introduces multi-labeled nodes, indexes over relationship properties, additional expressivity (construct, functions, and operators), major performance enhancements, and many bug fixes. </p> <h4 id="whats-new-in-28"> What's new in 2.8 </h4> <ul> <li> <p> Multi-labeled nodes </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> The <code> labels </code> function's signature has changed. The function now returns a list of labels instead of a single label. <br/> <br/> If you are using this function and upgrading to RedisGraph 2.8, a simple fix is to replace any call to <code> labels(x) </code> with <code> labels(x)[0] </code> . This returns the first label associated with node <code> x </code> . For uni-labeled nodes, the result in RedisGraph 2.8 is similar to the results of <code> labels(x) </code> in RedisGraph 2.4. </div> </div> </li> <li> <p> Indexes over relationship properties </p> </li> <li> <p> Enhanced full-text search </p> </li> <li> <p> Delta matrices: node and relationships additions and deletions are much faster, as they are first updated in small delta matrices. The main matrices are then bulk-updated. </p> </li> <li> <p> Additional Cypher construct, functions, and operators </p> </li> <li> <p> RediSearch 2.2.7 </p> </li> <li> <p> <a href="https://github.com/DrTimothyAldenDavis/GraphBLAS"> SuiteSparse </a> (GraphBLAS) 6.0.0 </p> </li> </ul> <h3 id="details"> Details </h3> <ul> <li> <p> Features (since 2.8-M02): </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2109"> #2109 </a> Introduce <code> allShortestPaths </code> BFS function </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2099"> #2099 </a> Introduce <code> keys </code> function </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2047"> #2047 </a> Introduce <code> reduce </code> function </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2076"> #2076 </a> Introduce XOR operation in filter trees </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2088"> #2088 </a> Introduce pattern comprehensions </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2051"> #2051 </a> Allow copying of entity attribute sets in <code> SET </code> clauses </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2067"> #2067 </a> Allow modification of virtual key entity count ( <code> VKEY_MAX_ENTITY_COUNT </code> ) at runtime </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2102"> #2102 </a> New load time configuration option <code> NODE_CREATION_BUFFER </code> - see <a href="https://github.com/RedisGraph/RedisGraph/blob/master/docs/docs/configuration.md#node_creation_buffer"> documentation </a> (MOD-2348) </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2049"> #2049 </a> RediSearch supports field definitions </li> </ul> </li> <li> <p> Performance improvements (since 2.8-M02): </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2097"> #2097 </a> Locks favor writers to prevent write exhaustion </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/1945"> #1945 </a> Track node count per label in graph statistics </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/1872"> #1872 </a> Delta matrices are always <a href="https://fossies.org/linux/SuiteSparse/GraphBLAS/docs/graphblas_demo.html#40"> hypersparse </a> </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/1871"> #1871 </a> Matrix sync policies reduce the number of syncs required </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/1869"> #1869 </a> Transposed matrices are always boolean </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2101"> #2101 </a> Entity annotation has been replaced with an AST <code> toString </code> function </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/1878"> #1878 </a> Slowlog queries no longer create graphs </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2067"> #2067 </a> Index graph entities incrementally on restore </li> <li> Faster AOF recovery (PM-1252) </li> </ul> </li> <li> <p> Bug fixes (since 2.8-M02): </p> <ul> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2016"> #2016 </a> Implement new BFS algorithm </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2105"> #2105 </a> Creating a node with multiple properties using the same key only accepts the last value </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2055"> #2055 </a> Avoid arithmetic overflow in <code> avg </code> function </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2048"> #2048 </a> Modulo by zero emits division by zero error </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2020"> #2020 </a> Fix evaluation of variable-length edges in expression ordering </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2028"> #2028 </a> Fix utilization of record offset in procedure calls, refactor outputs </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2014"> #2014 </a> Update label for every node in the AST </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2002"> #2002 </a> Fix crash in index utilization using wrong query_graph </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/1976"> #1976 </a> Use operand matrix when available </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/1973"> #1973 </a> Emit error on a query that only contains parameters </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/1950"> #1950 </a> Print ExecutionPlan in <code> GRAPH.EXPLAIN </code> only if no errors are encountered in the construction </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/1933"> #1933 </a> Free thread-local data on graph deletion </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/1942"> #1942 </a> Fix dimensions of transposed delta matrices </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/1940"> #1940 </a> Do not use block client if deny blocking is specified </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/1898"> #1898 </a> Error when setting a property to an array containing an invalid type </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/1931"> #1931 </a> Sync matrices on parent process before serialization fork </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/1897"> #1897 </a> Aliases in <code> WITH </code> ... <code> ORDER BY </code> must be valid references </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/1913"> #1913 </a> Update thread-local AST for every cloned operation </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/1915"> #1915 </a> Validate function references in parameters </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/1911"> #1911 </a> Refactor <code> cron </code> task for managing query timeouts </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/1902"> #1902 </a> Fix incorrect behavior on <code> NULL </code> values in <code> CASE </code> ... <code> WHEN </code> expressions </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/1904"> #1904 </a> Allow reconfiguring query timeout to 0 </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/1888"> #1888 </a> Synchronize matrices on creation in RDB load </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/1892"> #1892 </a> Validate values specified in <code> SET </code> clauses </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/1889"> #1889 </a> Tuple iterator now updates properly when changing matrix to serialize </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/1870"> #1870 </a> Fix crash in <code> range </code> function </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2125"> #2125 </a> Fix crash on <code> UNION </code> ... <code> RETURN </code> * queries (MOD-2524) </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2043"> #2043 </a> Avoid serialization of duplicate graph keys </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2067"> #2067 </a> Numeric indices no longer lose precision on very large values </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/issues/2072"> #2072 </a> , <a href="https://github.com/RedisGraph/RedisGraph/pull/2081"> #2081 </a> CRLF sequences embedded in strings no longer trigger a protocol error when being emitted </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2139"> #2139 </a> Fix crash when trying to retrieve an out-of-bounds item </li> <li> <a href="https://github.com/RedisGraph/RedisGraph/pull/2149"> #2149 </a> Fix crash when matching a node engages an index to search for a value that is a RediSearch stop word </li> </ul> </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisgraph/redisgraph-2.8-release-notes/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/references/cli-utilities/rladmin/placement/.html
<section class="prose w-full py-12 max-w-none"> <h1> rladmin placement </h1> <p class="text-lg -mt-5 mb-10"> Configures the shard placement policy for a database. </p> <p> Configures the shard placement policy for a specified database. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin placement </span></span><span class="line"><span class="cl"> db <span class="o">{</span> db:&lt;id&gt; <span class="p">|</span> &lt;name&gt; <span class="o">}</span> </span></span><span class="line"><span class="cl"> <span class="o">{</span> dense <span class="p">|</span> sparse <span class="o">}</span> </span></span></code></pre> </div> <h3 id="parameters"> Parameters </h3> <table> <thead> <tr> <th> Parameter </th> <th> Type/Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> db </td> <td> db:&lt;id&gt; <br/> name </td> <td> Configures shard placement for the specified database </td> </tr> <tr> <td> dense </td> <td> </td> <td> Places new shards on the same node as long as it has resources </td> </tr> <tr> <td> sparse </td> <td> </td> <td> Places new shards on the maximum number of available nodes within the cluster </td> </tr> </tbody> </table> <h3 id="returns"> Returns </h3> <p> Returns the new shard placement policy if the policy was changed successfully. Otherwise, it returns an error. </p> <p> Use <a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/status/#status-databases"> <code> rladmin status databases </code> </a> to verify that the failover completed. </p> <h3 id="example"> Example </h3> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ rladmin status databases </span></span><span class="line"><span class="cl">DATABASES: </span></span><span class="line"><span class="cl">DB:ID NAME TYPE STATUS SHARDS PLACEMENT REPLICATION PERSISTENCE ENDPOINT </span></span><span class="line"><span class="cl">db:5 tr01 redis active <span class="m">1</span> dense enabled aof redis-12000.cluster.local:12000 </span></span><span class="line"><span class="cl">$ rladmin placement db db:5 sparse </span></span><span class="line"><span class="cl">Shards placement policy is now sparse </span></span><span class="line"><span class="cl">$ rladmin status databases </span></span><span class="line"><span class="cl">DATABASES: </span></span><span class="line"><span class="cl">DB:ID NAME TYPE STATUS SHARDS PLACEMENT REPLICATION PERSISTENCE ENDPOINT </span></span><span class="line"><span class="cl">db:5 tr01 redis active <span class="m">1</span> sparse enabled aof redis-12000.cluster.local:12000 </span></span></code></pre> </div> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/cli-utilities/rladmin/placement/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/security/access-control/ldap/enable-role-based-ldap/.html
<section class="prose w-full py-12 max-w-none"> <h1> Enable role-based LDAP </h1> <p class="text-lg -mt-5 mb-10"> Describes how to enable role-based LDAP authentication and authorization using the Cluster Manager UI. </p> <p> Redis Enterprise Software uses a role-based mechanism to enable LDAP authentication and authorization. </p> <p> When a user attempts to access Redis Enterprise resources using LDAP credentials, the credentials are passed to the LDAP server in a bind request. If the request succeeds, the user’s groups are searched for a group that authorizes access to the original resource. </p> <p> Role-based LDAP lets you authorize cluster management users (previously known as <em> external users </em> ) and database users. As with any access control role, you can define the level of access authorized by the role. </p> <h2 id="set-up-ldap-connection"> Set up LDAP connection </h2> <p> To configure and enable LDAP from the Cluster Manager UI: </p> <ol> <li> <p> Go to <strong> Access Control &gt; LDAP &gt; Configuration </strong> . </p> </li> <li> <p> Select <strong> + Create </strong> . </p> </li> <li> <p> In <strong> Set LDAP </strong> , configure <a href="#ldap-server-settings"> LDAP server settings </a> , <a href="#bind-credentials"> bind credentials </a> , <a href="#authentication-query"> authentication query </a> , and <a href="#authorization-query"> authorization query </a> . </p> <a href="/docs/latest/images/rs/screenshots/access-control/ldap-config.png" sdata-lightbox="/images/rs/screenshots/access-control/ldap-config.png"> <img alt="The LDAP configuration screen in the Cluster Manager UI" src="/docs/latest/images/rs/screenshots/access-control/ldap-config.png"/> </a> </li> <li> <p> Select <strong> Save &amp; Enable </strong> . </p> </li> </ol> <h3 id="ldap-server-settings"> LDAP server settings </h3> <p> The <strong> LDAP server </strong> settings define the communication settings used for LDAP authentication and authorization. These include: </p> <table> <thead> <tr> <th style="text-align:left"> <em> Setting </em> </th> <th style="text-align:left"> <em> Description </em> </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> <strong> Protocol type </strong> </td> <td style="text-align:left"> Underlying communication protocol; must be <em> LDAP </em> , <em> LDAPS </em> , or <em> STARTTLS </em> </td> </tr> <tr> <td style="text-align:left"> <strong> Host </strong> </td> <td style="text-align:left"> URL of the LDAP server </td> </tr> <tr> <td style="text-align:left"> <strong> Port </strong> </td> <td style="text-align:left"> LDAP server port number </td> </tr> <tr> <td style="text-align:left"> <strong> Trusted CA certificate </strong> </td> <td style="text-align:left"> <em> (LDAPS or STARTTLS protocols only) </em> Certificate for the trusted certificate authority (CA) </td> </tr> </tbody> </table> <p> When defining multiple LDAP hosts, the organization tree structure must be identical for all hosts. </p> <h3 id="bind-credentials"> Bind credentials </h3> <p> These settings define the credentials for the bind query: </p> <table> <thead> <tr> <th style="text-align:left"> <em> Setting </em> </th> <th style="text-align:left"> <em> Description </em> </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> <strong> Distinguished Name </strong> </td> <td style="text-align:left"> Example: <code> cd=admin,dc=example,dc=org </code> </td> </tr> <tr> <td style="text-align:left"> <strong> Password </strong> </td> <td style="text-align:left"> Example: <code> admin1 </code> </td> </tr> <tr> <td style="text-align:left"> <strong> Client certificate authentication </strong> </td> <td style="text-align:left"> <em> (LDAPS or STARTTLS protocols only) </em> Place checkmark to enable </td> </tr> <tr> <td style="text-align:left"> <strong> Client public key </strong> </td> <td style="text-align:left"> <em> (LDAPS or STARTTLS protocols only) </em> The client public key for authentication </td> </tr> <tr> <td style="text-align:left"> <strong> Client private key </strong> </td> <td style="text-align:left"> <em> (LDAPS or STARTTLS protocols only) </em> The client private key for authentication </td> </tr> </tbody> </table> <h3 id="authentication-query"> Authentication query </h3> <p> These settings define the authentication query: </p> <table> <thead> <tr> <th style="text-align:left"> <em> Setting </em> </th> <th style="text-align:left"> <em> Description </em> </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> <strong> Search user by </strong> </td> <td style="text-align:left"> Either <em> Template </em> or <em> Query </em> </td> </tr> <tr> <td style="text-align:left"> <strong> Template </strong> </td> <td style="text-align:left"> <em> (template search) </em> Example: <code> cn=%u,ou=dev,dc=example,dc=com </code> </td> </tr> <tr> <td style="text-align:left"> <strong> Base </strong> </td> <td style="text-align:left"> <em> (query search) </em> Example: <code> ou=dev,dc=example,dc=com </code> </td> </tr> <tr> <td style="text-align:left"> <strong> Filter </strong> </td> <td style="text-align:left"> <em> (query search) </em> Example: <code> (cn=%u) </code> </td> </tr> <tr> <td style="text-align:left"> <strong> Scope </strong> </td> <td style="text-align:left"> <em> (query search) </em> Must be <em> baseObject </em> , <em> singleLevel </em> , or <em> wholeSubtree </em> </td> </tr> </tbody> </table> <p> In this example, <code> %u </code> is replaced by the username attempting to access the Redis Enterprise resource. </p> <h3 id="authorization-query"> Authorization query </h3> <p> These settings define the group authorization query: </p> <table> <thead> <tr> <th style="text-align:left"> <em> Setting </em> </th> <th style="text-align:left"> <em> Description </em> </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> <strong> Search groups by </strong> </td> <td style="text-align:left"> Either <em> Attribute </em> or <em> Query </em> </td> </tr> <tr> <td style="text-align:left"> <strong> Attribute </strong> </td> <td style="text-align:left"> <em> (attribute search) </em> Example: <code> memberOf </code> (case-sensitive) </td> </tr> <tr> <td style="text-align:left"> <strong> Base </strong> </td> <td style="text-align:left"> <em> (query search) </em> Example: <code> ou=groups,dc=example,dc=com </code> </td> </tr> <tr> <td style="text-align:left"> <strong> Filter </strong> </td> <td style="text-align:left"> <em> (query search) </em> Example: <code> (members=%D) </code> </td> </tr> <tr> <td style="text-align:left"> <strong> Scope </strong> </td> <td style="text-align:left"> <em> (query search) </em> Must be <em> baseObject </em> , <em> singleLevel </em> , or <em> wholeSubtree </em> </td> </tr> </tbody> </table> <p> In this example, <code> %D </code> is replaced by the Distinguished Name of the user attempting to access the Redis Enterprise resource. </p> <h3 id="authentication-timeout"> Authentication timeout </h3> <p> The <strong> Authentication timeout </strong> setting determines the connection timeout to the LDAP server during user authentication. </p> <p> By default, the timeout is 5 seconds, which is recommended for most cases. </p> <p> However, if you enable multi-factor authentication (MFA) for your LDAP server, you might need to increase the timeout to provide enough time for MFA verification. You can set it to any integer in the range of 5-60 seconds. </p> <h2 id="more-info"> More info </h2> <ul> <li> Map LDAP groups to <a href="/docs/latest/operate/rs/security/access-control/ldap/map-ldap-groups-to-roles/"> access control roles </a> </li> <li> Update database ACLs to <a href="/docs/latest/operate/rs/security/access-control/ldap/update-database-acls/"> authorize LDAP access </a> </li> <li> Learn more about Redis Software <a href="/docs/latest/operate/rs/security/"> security and practices </a> </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/security/access-control/ldap/enable-role-based-ldap/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/references/cli-utilities/rladmin/node/remove/.html
<section class="prose w-full py-12 max-w-none"> <h1> rladmin node remove </h1> <p class="text-lg -mt-5 mb-10"> Removes a node from the cluster. </p> <p> Removes the specified node from the cluster. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin node &lt;ID&gt; remove <span class="o">[</span> wait_for_persistence <span class="o">{</span> enabled <span class="p">|</span> disabled <span class="o">}</span> <span class="o">]</span> </span></span></code></pre> </div> <h3 id="parameters"> Parameters </h3> <table> <thead> <tr> <th> Parameter </th> <th> Type/Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> node </td> <td> integer </td> <td> The node to remove from the cluster </td> </tr> <tr> <td> wait_for_persistence </td> <td> <code> enabled </code> <br/> <code> disabled </code> </td> <td> Ensures persistence files are available for recovery. The cluster policy <code> persistent_node_removal </code> determines the default value. </td> </tr> </tbody> </table> <h3 id="returns"> Returns </h3> <p> Returns <code> OK </code> if the node was removed successfully. Otherwise, it returns an error. </p> <p> Use <a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/status/#status-nodes"> <code> rladmin status nodes </code> </a> to verify that the node was removed. </p> <h3 id="example"> Example </h3> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ rladmin status nodes </span></span><span class="line"><span class="cl">CLUSTER NODES: </span></span><span class="line"><span class="cl">NODE:ID ROLE ADDRESS EXTERNAL_ADDRESS HOSTNAME SHARDS CORES FREE_RAM PROVISIONAL_RAM VERSION STATUS </span></span><span class="line"><span class="cl">*node:1 master 192.0.2.12 198.51.100.1 3d99db1fdf4b 5/100 <span class="m">6</span> 14.26GB/19.54GB 10.67GB/16.02GB 6.2.12-37 OK </span></span><span class="line"><span class="cl">node:2 slave 192.0.2.13 198.51.100.2 fc7a3d332458 4/100 <span class="m">6</span> 14.26GB/19.54GB 10.71GB/16.02GB 6.2.12-37 OK </span></span><span class="line"><span class="cl">node:3 slave 192.0.2.14 b87cc06c830f 1/120 <span class="m">6</span> 14.26GB/19.54GB 10.7GB/16.02GB 6.2.12-37 OK </span></span><span class="line"><span class="cl">$ rladmin node <span class="m">3</span> remove </span></span><span class="line"><span class="cl">Performing remove action on node:3: 100% </span></span><span class="line"><span class="cl">OK </span></span><span class="line"><span class="cl">CLUSTER NODES: </span></span><span class="line"><span class="cl">NODE:ID ROLE ADDRESS EXTERNAL_ADDRESS HOSTNAME SHARDS CORES FREE_RAM PROVISIONAL_RAM VERSION STATUS </span></span><span class="line"><span class="cl">*node:1 master 192.0.2.12 198.51.100.1 3d99db1fdf4b 5/100 <span class="m">6</span> 14.34GB/19.54GB 10.74GB/16.02GB 6.2.12-37 OK </span></span><span class="line"><span class="cl">node:2 slave 192.0.2.13 198.51.100.2 fc7a3d332458 5/100 <span class="m">6</span> 14.34GB/19.54GB 10.74GB/16.02GB 6.2.12-37 OK </span></span></code></pre> </div> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/cli-utilities/rladmin/node/remove/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/requests/bdbs/actions/recover/.html
<section class="prose w-full py-12 max-w-none"> <h1> Recover database requests </h1> <p class="text-lg -mt-5 mb-10"> REST API requests for database recovery </p> <table> <thead> <tr> <th> Method </th> <th> Path </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="#get-bdbs-actions-recover"> GET </a> </td> <td> <code> /v1/bdbs/{uid}/actions/recover </code> </td> <td> Get database recovery plan </td> </tr> <tr> <td> <a href="#post-bdbs-actions-recover"> POST </a> </td> <td> <code> /v1/bdbs/{uid}/actions/recover </code> </td> <td> Recover database </td> </tr> </tbody> </table> <h2 id="get-bdbs-actions-recover"> Get recovery plan </h2> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">GET /v1/bdbs/<span class="o">{</span>int: uid<span class="o">}</span>/actions/recover </span></span></code></pre> </div> <p> Fetches the recovery plan for a database. The recovery plan provides information about the recovery status, such as whether recovery is possible, and details on available files to use for recovery. </p> <h4 id="required-permissions"> Required permissions </h4> <table> <thead> <tr> <th> Permission name </th> <th> Roles </th> </tr> </thead> <tbody> <tr> <td> <a href="/docs/latest/operate/rs/7.4/references/rest-api/permissions/#view_bdb_recovery_plan"> view_bdb_recovery_plan </a> </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer </td> </tr> </tbody> </table> <h3 id="get-request"> Request </h3> <h4 id="example-http-request"> Example HTTP request </h4> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">GET /bdbs/1/actions/recover </span></span></code></pre> </div> <h4 id="url-parameters"> URL parameters </h4> <table> <thead> <tr> <th> Field </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> uid </td> <td> integer </td> <td> The unique ID of the database. </td> </tr> </tbody> </table> <h3 id="get-response"> Response </h3> <p> Returns a JSON object that represents the database's recovery plan, including recovery files and status. </p> <h4 id="example-response-body"> Example response body </h4> <div class="highlight"> <pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"data_files"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"filename"</span><span class="p">:</span> <span class="s2">"appendonly-1.aof"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"last_modified"</span><span class="p">:</span> <span class="mf">1721164863.8883622</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"node_uid"</span><span class="p">:</span> <span class="s2">"1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"shard_role"</span><span class="p">:</span> <span class="s2">"master"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"shard_slots"</span><span class="p">:</span> <span class="s2">"1-2048"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"shard_uid"</span><span class="p">:</span> <span class="s2">"1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"size"</span><span class="p">:</span> <span class="mi">88</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"filename"</span><span class="p">:</span> <span class="s2">"appendonly-2.aof"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"last_modified"</span><span class="p">:</span> <span class="mf">1721164863.8883622</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"node_uid"</span><span class="p">:</span> <span class="s2">"2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"shard_role"</span><span class="p">:</span> <span class="s2">"slave"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"shard_slots"</span><span class="p">:</span> <span class="s2">"2049-4096"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"shard_uid"</span><span class="p">:</span> <span class="s2">"2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"size"</span><span class="p">:</span> <span class="mi">88</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="nt">"status"</span><span class="p">:</span> <span class="s2">"ready"</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <h4 id="get-status-codes"> Status codes </h4> <table> <thead> <tr> <th> Code </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-200-ok"> 200 OK </a> </td> <td> No error. </td> </tr> <tr> <td> <a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-404-not-found"> 404 Not Found </a> </td> <td> Database UID does not exist. </td> </tr> </tbody> </table> <h2 id="post-bdbs-actions-recover"> Recover database </h2> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">POST /v1/bdbs/<span class="o">{</span>int: uid<span class="o">}</span>/actions/recover </span></span></code></pre> </div> <p> Initiates <a href="/docs/latest/operate/rs/7.4/databases/recover/"> recovery for a database </a> in a recoverable state where all the database's files are available after <a href="/docs/latest/operate/rs/7.4/clusters/cluster-recovery/"> cluster recovery </a> . </p> <h4 id="required-permissions-1"> Required permissions </h4> <table> <thead> <tr> <th> Permission name </th> <th> Roles </th> </tr> </thead> <tbody> <tr> <td> <a href="/docs/latest/operate/rs/7.4/references/rest-api/permissions/#start_bdb_recovery"> start_bdb_recovery </a> </td> <td> admin <br/> cluster_member <br/> db_member </td> </tr> </tbody> </table> <h3 id="post-request"> Request </h3> <p> The request body can either be empty or include a recovery plan. </p> <p> If the request body is empty, the database will be recovered automatically: </p> <ul> <li> <p> Databases with no persistence are recovered with no data. </p> </li> <li> <p> Persistent files such as AOF or RDB will be loaded from their expected storage locations where replica or primary shards were last active. </p> </li> <li> <p> If persistent files are not found where expected but can be located on other cluster nodes, they will be used. </p> </li> </ul> <h4 id="example-http-request-1"> Example HTTP request </h4> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">POST /bdbs/1/actions/recover </span></span></code></pre> </div> <h4 id="example-request-body"> Example request body </h4> <div class="highlight"> <pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"data_files"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"filename"</span><span class="p">:</span> <span class="s2">"appendonly-1.aof"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"node_uid"</span><span class="p">:</span> <span class="s2">"1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"shard_slots"</span><span class="p">:</span> <span class="s2">"1-2048"</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"filename"</span><span class="p">:</span> <span class="s2">"appendonly-2.aof"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"node_uid"</span><span class="p">:</span> <span class="s2">"2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"shard_slots"</span><span class="p">:</span> <span class="s2">"2049-4096"</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="nt">"ignore_errors"</span><span class="p">:</span> <span class="kc">false</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"recover_without_data"</span><span class="p">:</span> <span class="kc">false</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <h4 id="url-parameters-1"> URL parameters </h4> <table> <thead> <tr> <th> Field </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> uid </td> <td> integer </td> <td> The unique ID of the database to recover. </td> </tr> </tbody> </table> <h3 id="post-response"> Response </h3> <p> Returns a status code. Also returns a JSON object with an <code> action_uid </code> in the request body if successful. </p> <h4 id="post-status-codes"> Status codes </h4> <table> <thead> <tr> <th> Code </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-200-ok"> 200 OK </a> </td> <td> The request is accepted and is being processed. When the database is recovered, its status will become <code> active </code> . </td> </tr> <tr> <td> <a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-404-not-found"> 404 Not Found </a> </td> <td> Attempting to perform an action on a nonexistent database. </td> </tr> <tr> <td> <a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-409-conflict"> 409 Conflict </a> </td> <td> Database is currently busy with another action, recovery is already in progress, or is not in a recoverable state. </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/requests/bdbs/actions/recover/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/release-notes/rs-7-2-4-releases/rs-7-2-4-52/.html
<section class="prose w-full py-12 max-w-none"> <h1> Redis Enterprise Software release notes 7.2.4-52 (August 2023) </h1> <p class="text-lg -mt-5 mb-10"> Redis 7.0 and 7.2 features. Auto Tiering (enhanced successor to Redis on Flash). RESP3 support. Sharded pub/sub. Preview of the new Cluster Manager UI. Redis Stack 7.2 features. Three Redis database versions. License file structure updates. Redis ACL selectors and enhanced key-based permissions. New INFO fields. Log rotation enhancements. Multi-OS upgrade support for clusters with modules. </p> <p> ​ <a href="https://redis.com/redis-enterprise-software/download-center/software/"> ​Redis Enterprise Software version 7.2.4 </a> is now available! </p> <h2 id="highlights"> Highlights </h2> <p> This version offers: </p> <ul> <li> <p> Redis 7.0 and 7.2 features </p> </li> <li> <p> Auto Tiering (enhanced successor to Redis on Flash) </p> </li> <li> <p> RESP3 support </p> </li> <li> <p> Sharded pub/sub </p> </li> <li> <p> A preview of the new Cluster Manager UI (admin console) </p> </li> <li> <p> Redis Stack 7.2 features </p> </li> <li> <p> Three Redis database versions: 7.2, 6.2, 6.0 </p> </li> <li> <p> License file structure updates </p> </li> <li> <p> Redis ACL selectors and enhanced key-based permissions </p> </li> <li> <p> New INFO fields </p> </li> <li> <p> Log rotation enhancements </p> </li> <li> <p> Multi-OS upgrade support for clusters with modules </p> </li> </ul> <h2 id="new-in-this-release"> New in this release </h2> <h3 id="new-features"> New features </h3> <h4 id="redis-70-features"> Redis 7.0 features </h4> <p> The following Redis 7.0 features are now supported: </p> <ul> <li> <p> <a href="/docs/latest/develop/interact/programmability/functions-intro/"> Redis functions </a> </p> <p> In Redis Enterprise Software, <a href="/docs/latest/commands/function-stats/"> <code> FUNCTION STATS </code> </a> returns an extra parameter, an array called <code> all_running_scripts </code> , to reflect multiple functions running at the same time. </p> </li> <li> <p> <a href="/docs/latest/operate/oss_and_stack/management/persistence/#append-only-file"> Multipart AOF </a> (append-only files) </p> </li> <li> <p> New commands </p> </li> <li> <p> Sharded <code> PUBSUB </code> (see <a href="#sharded-pubsub"> Sharded pub/sub </a> for details) </p> </li> </ul> <h4 id="redis-72-features"> Redis 7.2 features </h4> <p> The following Redis 7.2 features are now supported: </p> <ul> <li> <p> Various performance improvements </p> </li> <li> <p> <code> CONFIG SET </code> for locale </p> </li> <li> <p> Connection layer modularization </p> </li> <li> <p> Encoding improvements: listpack for sets and lists </p> </li> <li> <p> Observability: authentication metrics (exposed by <code> INFO </code> command) </p> </li> <li> <p> Stream consumer group improvements </p> </li> <li> <p> Commands: <code> ZRANK </code> , <code> ZREVRANK </code> new <code> WITHSCORE </code> option </p> </li> <li> <p> Shard IDs in cluster shards topology </p> </li> <li> <p> Introduce shard ID to Redis cluster </p> </li> <li> <p> Support <code> CLIENT NO-TOUCH </code> command </p> </li> <li> <p> <code> WAIT AOF </code> </p> </li> </ul> <h4 id="auto-tiering"> Auto Tiering - Redis on Flash evolution doubles throughput and reduces latency </h4> <p> Redis Enterprise version 7.2 introduces Auto Tiering as an enhanced successor to Redis on Flash, which allows you to provision larger databases at a lower cost by extending the RAM with flash drives. </p> <p> Redis Enterprise Auto Tiering replaces RocksDB with <a href="https://www.speedb.io/"> Speedb </a> as its storage engine, doubling the throughput and reducing latencies, achieved using the same infrastructure resources. For example, a 1 TB database with 50K ops/sec can now serve 100K ops/sec based on the same infrastructure. </p> <p> To switch existing databases to use Speedb for Auto Tiering and improve performance: </p> <ol> <li> <p> Upgrade the cluster to Redis Enterprise Software version 7.2.4. </p> </li> <li> <p> Upgrade each database with Auto Tiering enabled to Redis database version 7.2. </p> </li> </ol> <p> For more information about Auto Tiering, see: </p> <ul> <li> <p> <a href="/docs/latest/operate/rs/databases/auto-tiering/"> Auto Tiering overview </a> </p> </li> <li> <p> <a href="/docs/latest/operate/rs/databases/auto-tiering/quickstart/"> Auto Tiering quick start </a> </p> </li> </ul> <h4 id="resp3-support"> RESP3 support </h4> <p> Support for RESP3 and the <a href="/docs/latest/commands/hello/"> <code> HELLO </code> </a> command was added in Redis Enterprise 7.2. </p> <p> To use RESP3 with Redis Enterprise: </p> <ol> <li> <p> Upgrade Redis servers to version 7.2 or later. </p> <p> For Active-Active and Replica Of databases: </p> <ol> <li> <p> Upgrade all participating clusters to Redis Enterprise version 7.2.x or later. </p> </li> <li> <p> Upgrade all databases to version 7.x or later. </p> </li> </ol> </li> <li> <p> Enable RESP3 support for your database ( <code> enabled </code> by default): </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin tune db db:&lt;ID&gt; resp3 enabled </span></span></code></pre> </div> </li> </ol> <p> If you run Redis Stack commands with Redis clients <a href="https://redis.uptrace.dev/"> Go-Redis </a> version 9 or <a href="https://redis.github.io/lettuce/"> Lettuce </a> versions 6 and later, see <a href="#client-prerequisites-for-redis-72-upgrade"> client prerequisites </a> before you upgrade to Redis 7.2 to learn how to prevent potential application issues due to RESP3 breaking changes. </p> <h4 id="sharded-pubsub"> Sharded pub/sub </h4> <p> <a href="/docs/latest/develop/interact/pubsub/#sharded-pubsub"> Sharded pub/sub </a> is now supported. </p> <p> You cannot use sharded pub/sub if you <a href="/docs/latest/operate/rs/references/compatibility/resp/#deactivate-resp3"> deactivate RESP3 support </a> . </p> <h4 id="new-cluster-manager-ui-preview"> New Cluster Manager UI preview </h4> <p> A preview of the new Cluster Manager UI (admin console) is available in Redis Enterprise Software version 7.2.4. </p> <p> To try out the new UI: </p> <ul> <li> <p> On the sign-in screen: </p> <ol> <li> <p> Enter your credentials. </p> </li> <li> <p> Select <strong> Sign in the new interface </strong> . </p> </li> </ol> </li> <li> <p> Sign in directly from the new UI's sign-in screen at <nobr> <code> https://&lt;hostname or IP address&gt;:8443/new </code> </nobr> </p> </li> <li> <p> If you are currently signed in to the legacy UI: </p> <ol> <li> <p> Select <strong> Switch to the new Admin Console </strong> to expand the banner at the top of the screen. </p> </li> <li> <p> Click the <strong> Try it now </strong> button to open the new UI in another tab. </p> </li> </ol> </li> </ul> <h5 id="new-ui-benefits"> New UI benefits </h5> <ul> <li> <p> User-driven design </p> </li> <li> <p> Provides full functionality to complete tasks entirely in the UI </p> </li> <li> <p> New attributes and improved feature visibility </p> </li> <li> <p> Provides configuration flexibility while highlighting the recommended path </p> </li> <li> <p> Addresses the needs of different personas and use cases </p> </li> <li> <p> Quicker troubleshooting and easier maintenance </p> </li> </ul> <h5 id="new-ui-highlights"> New UI highlights </h5> <ul> <li> <p> More configurable database attributes, including replica high availability, shards placement, and proxy policy. </p> </li> <li> <p> Nodes indicate whether it’s a primary or secondary node. </p> </li> <li> <p> Modules show the databases that are using them. </p> </li> <li> <p> Certificates show expiration and validity, and you can upload and copy certificates. </p> </li> <li> <p> Cluster license displays the number of shards that are used out of the number of shards that are licensed to the cluster. The new UI allows you to paste or upload a new license. </p> </li> <li> <p> Role-based access control (RBAC) has explanations to improve clarity. </p> </li> <li> <p> Access Control List (ACLs) now support defining ACLs for modules. </p> </li> <li> <p> The databases screen has more information per database for faster troubleshooting. It also allows you to filter databases and compare database metrics. </p> </li> <li> <p> The cluster name, user, and user role are shown in the upper right for quickly identifying the cluster from any screen. You can also <strong> Change user password </strong> from the dropdown menu. </p> </li> <li> <p> Auto Tiering licensing and a toggle for the storage engine used in Auto Tiering enabled databases (available only in the new UI). </p> </li> <li> <p> Input validations. </p> </li> </ul> <h5 id="new-ui-limitations"> New UI limitations </h5> <p> The following features are not supported in this preview but will be added in future releases. Until then, temporarily switch to the legacy UI to do the following: </p> <ul> <li> <p> Provision and configure Active-Active databases (viewing is available). </p> </li> <li> <p> Search and export the event log. </p> </li> <li> <p> Remove a node from the UI. </p> </li> </ul> <p> Additional limitations: </p> <ul> <li> Although Redis supports memcached databases, the new UI only allows view and delete. Memcached users are advised to migrate to Redis to enjoy the full benefits of Redis and its UI. </li> </ul> <p> To open the legacy admin console when signed in to the new UI, select your username, then select <strong> Switch to legacy Admin Console </strong> from the list: </p> <a href="/docs/latest/images/rs/screenshots/switch-to-legacy-ui.png" sdata-lightbox="/images/rs/screenshots/switch-to-legacy-ui.png"> <img alt="Select switch to legacy admin console from the dropdown." src="/docs/latest/images/rs/screenshots/switch-to-legacy-ui.png" width="300px"/> </a> <h5 id="future-ui-enhancements"> Future UI enhancements </h5> <ul> <li> <p> Configure default database settings and database upgrade settings </p> </li> <li> <p> Security preferences related to password and login management </p> </li> <li> <p> LDAP improvements </p> </li> <li> <p> IPv6 support </p> </li> <li> <p> ACL improvements, such as ACLv2 smart validations </p> </li> <li> <p> And more </p> </li> </ul> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> With the release of the new Cluster Manager UI, the legacy UI is considered deprecated and will eventually be phased out. New functionality will only be implemented in the new Cluster Manager UI, and the old UI will no longer be maintained except for critical bug fixes. </div> </div> <h4 id="redis-stack-72-features"> Redis Stack 7.2 features </h4> <p> Redis Enterprise Software version 7.2.4 supports features included in Redis Stack version 7.2. </p> <p> The following sections include a few highlights. For more details, see the <a href="https://github.com/redis-stack/redis-stack/releases/tag/v7.2.0-v0"> Redis Stack 7.2 release notes </a> . </p> <h5 id="search-and-query"> Search and query </h5> <ul> <li> <p> Introduces <a href="/docs/latest/commands/ft.search#examples"> Geo Polygon </a> Search. Geo range queries now accept the <a href="/docs/latest/commands/ft.create#required-arguments"> <code> GEOSHAPE </code> </a> field type, which supports polygon shapes using <a href="https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry"> WKT notation </a> . <code> GEOSHAPE </code> supports <code> POLYGON </code> and <code> POINT </code> as shape formats and polygon operations. </p> </li> <li> <p> Performance improvements for <code> SORT BY </code> operations using <a href="/docs/latest/commands/ft.search#optional-arguments"> <code> FT.SEARCH </code> </a> and <a href="/docs/latest/commands/ft.aggregate#optional-arguments"> <code> FT.AGGREGATE </code> </a> . </p> </li> <li> <p> New <code> FORMAT </code> for improved readability and future support for better error handling responses on <code> FT.SEARCH </code> and <code> FT.AGGREGATE </code> in RESP3 only. </p> </li> </ul> <h5 id="json"> JSON </h5> <p> JSON introduces two new commands: </p> <ul> <li> <p> <a href="/docs/latest/commands/json.merge"> JSON.MERGE </a> merges a given JSON value into matching paths to update, delete, or expand the JSON values at the matching paths. </p> </li> <li> <p> <a href="/docs/latest/commands/json.mset"> JSON.MSET </a> sets or updates one or more JSON values according to specified key-path-value triplets. </p> </li> </ul> <h5 id="triggers-and-functions-preview"> Triggers and functions preview </h5> <p> A preview of triggers and functions is available. </p> <p> Triggers and functions provide support for running JavaScript functions inside the Redis process. These functions can be executed on-demand, by an event-driven trigger, or by a stream processing trigger. </p> <p> Try it out with the <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/deprecated-features/triggers-and-functions/quick_start_ri/"> triggers and functions quick start </a> . </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> <ul> <li> <p> The preview version of triggers and functions is not intended for production use since the API might change in the future and potentially cause application issues when upgrading to a later version. </p> </li> <li> <p> During preview, triggers and functions are not supported for databases with Auto Tiering enabled (previously known as Redis on Flash). </p> </li> </ul> </div> </div> <h5 id="module-versions"> Module versions </h5> <p> Redis Enterprise Software version 7.2.4 includes the following Redis Stack modules: </p> <ul> <li> <p> <a href="https://github.com/RediSearch/RediSearch/releases/tag/v2.8.4"> RediSearch 2.8.4 </a> </p> </li> <li> <p> <a href="https://github.com/RedisJSON/RedisJSON/releases/tag/v2.6.6"> RedisJSON 2.6.6 </a> </p> </li> <li> <p> <a href="https://github.com/RedisTimeSeries/RedisTimeSeries/releases/tag/v1.10.4"> RedisTimeSeries 1.10.4 </a> </p> </li> <li> <p> <a href="https://github.com/RedisBloom/RedisBloom/releases/tag/v2.6.3"> RedisBloom 2.6.3 </a> </p> </li> <li> <p> <a href="https://github.com/RedisGears/RedisGears/releases/tag/v2.0.11-m12"> RedisGears 2.0.11 </a> </p> </li> </ul> <p> See <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/install/upgrade-module/"> Upgrade modules </a> to learn how to upgrade a module for a database. </p> <h3 id="enhancements"> Enhancements </h3> <h4 id="three-redis-database-versions"> Three Redis database versions </h4> <p> Redis Enterprise Software version 6.x includes two Redis database versions: 6.0 and 6.2. As of version 7.2, Redis Enterprise Software includes three Redis database versions: 6.0, 6.2, and 7.2. </p> <p> To view available Redis database versions: </p> <ul> <li> <p> In the Cluster Manager UI, see <strong> Redis database versions </strong> on the <strong> Cluster &gt; Configuration </strong> screen. </p> </li> <li> <p> Send a <a href="/docs/latest/operate/rs/references/rest-api/requests/nodes/"> <code> GET /nodes </code> REST API request </a> and see <code> supported_database_versions </code> in the response. </p> </li> </ul> <p> The default Redis database version, which is used when you upgrade an existing database or create a new one, differs between Redis Enterprise releases as follows: </p> <table> <thead> <tr> <th> Redis <br/> Enterprise </th> <th> Bundled Redis <br/> DB versions </th> <th> Default DB version <br/> (upgraded/new databases) </th> </tr> </thead> <tbody> <tr> <td> 7.2 </td> <td> 6.0, 6.2, 7.2 </td> <td> 7.2 </td> </tr> <tr> <td> 6.4.2 </td> <td> 6.0, 6.2 </td> <td> 6.2 </td> </tr> <tr> <td> 6.2.x </td> <td> 6.0, 6.2 </td> <td> 6.0 </td> </tr> </tbody> </table> <p> For Redis Enterprise Software version 7.2.4, <code> default_redis_version </code> is 7.2 for both <code> major </code> and <code> latest </code> upgrade policies. </p> <h4 id="updated-redis-enterprise-license-format"> Updated Redis Enterprise license format </h4> <p> Redis Enterprise Software version 7.2.4 includes updates to its license format, which add separate shard limits for RAM and flash shards used for Auto Tiering. </p> <p> For more information, see <a href="/docs/latest/operate/rs/clusters/configure/license-keys/"> Cluster license keys </a> . </p> <h4 id="redis-acl-selectors-and-key-based-permissions"> Redis ACL selectors and key-based permissions </h4> <p> Redis ACLs in Redis Enterprise version 7.2 support key permissions and selectors. </p> <p> Key permissions: </p> <ul> <li> <p> <code> %R~&lt;pattern&gt; </code> : Grants read access to keys that match the given pattern. </p> </li> <li> <p> <code> %W~&lt;pattern&gt; </code> : Grants write access to keys that match the given pattern. </p> </li> <li> <p> <code> %RW~&lt;pattern&gt; </code> : Alias for <code> ~&lt;pattern&gt; </code> . Grants read and write access to keys that match the given pattern. </p> <p> See <a href="/docs/latest/operate/oss_and_stack/management/security/acl/#key-permissions"> key permissions </a> for more information. </p> </li> </ul> <p> Selectors let you define multiple sets of rules in a single Redis ACL (only supported for databases with Redis version 7.2 or later). A command is allowed if it matches the base rule or any selector in the Redis ACL. See <a href="/docs/latest/operate/oss_and_stack/management/security/acl/#selectors"> selectors </a> for more information. </p> <ul> <li> <p> <code> (&lt;rule list&gt;) </code> : Creates a new selector. </p> </li> <li> <p> <code> clearselectors </code> : Deletes all existing selectors for a user. This action does not delete the base ACL rule. </p> </li> </ul> <p> Redis ACLs have the following differences in Redis Enterprise Software: </p> <ul> <li> <p> Nested selectors are not supported. </p> <p> For example, the following selectors are not valid in Redis Enterprise: <nobr> <code> +GET ~key1 (+SET (+SET ~key2) ~key3) </code> </nobr> </p> </li> <li> <p> Key and pub/sub patterns do not allow the following characters: <code> '(', ')' </code> </p> </li> <li> <p> The following password syntax is not supported: <code> '&gt;', '&lt;', '#!', 'resetpass' </code> </p> <p> To change passwords in Redis Enterprise Software, use one of the following methods: </p> <ul> <li> <p> Cluster Manager UI (admin console) </p> </li> <li> <p> <a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/cluster/reset_password/"> <code> rladmin cluster reset_password </code> </a> : </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin cluster reset_password &lt;user email&gt; </span></span></code></pre> </div> </li> <li> <p> REST API <a href="/docs/latest/operate/rs/references/rest-api/requests/users/#put-user"> <code> PUT /v1/users </code> </a> request and provide <code> password </code> </p> </li> </ul> </li> <li> <p> The <strong> ACL builder </strong> does not support selectors and key permissions. Use <strong> Free text command </strong> to manually define them instead. </p> </li> </ul> <h4 id="new-info-fields"> New INFO fields </h4> <p> The <a href="/docs/latest/commands/info/"> <code> INFO </code> </a> command includes new fields: </p> <ul> <li> <p> Under the <code> STATS </code> section: </p> <ul> <li> <p> <code> current_eviction_exceeded_time </code> - Redis Enterprise reply is always β€œ0” </p> </li> <li> <p> <code> total_eviction_exceeded_time </code> - Redis Enterprise reply is always β€œ0” </p> </li> <li> <p> <code> current_active_defrag_time </code> - Redis Enterprise reply is always β€œ0” </p> </li> <li> <p> <code> total_active_defrag_time </code> - Redis Enterprise reply is always β€œ0” </p> </li> </ul> </li> <li> <p> Under the <code> MEMORY </code> section: </p> <ul> <li> <code> maxmemory_policy </code> - The value of the <code> maxmemory-policy </code> configuration directive </li> </ul> </li> </ul> <p> The <code> INFO </code> command can now accept multiple section arguments (requires Redis database version 7 or later). </p> <h4 id="log-rotation-enhancements"> Log rotation enhancements </h4> <ul> <li> <p> The <code> logrotate </code> tool rotates logs that exceed 200 MB. </p> </li> <li> <p> <code> logrotate </code> runs every five minutes instead of once a day. </p> </li> <li> <p> The job scheduler runs <code> logrotate </code> instead of the OS. </p> </li> <li> <p> Every cluster upgrade overwrites the log rotation configuration. </p> </li> <li> <p> You can edit the log rotation configuration at <code> $pkgconfdir/logrotate.conf </code> ( <code> pkgconfdir </code> is <code> /opt/redislabs/config </code> by default, but can be changed in a custom installation). Note that the configuration file moved since last version. </p> </li> <li> <p> You can change how often the <code> logrotate </code> tool runs using the job scheduler REST API request <nobr> <code> PUT /v1/job_scheduler </code> </nobr> . </p> </li> </ul> <h4 id="os-upgrades-with-modules"> Multi-OS upgrade support for clusters with modules </h4> <p> Starting from Redis Enterprise version 7.2, all future 7.2.x upgrades are supported for clusters containing databases with modules in combination with Operating System (OS) upgrades. </p> <h3 id="resolved-issues"> Resolved issues </h3> <ul> <li> <p> RS54131 - <code> +OK </code> reply not received on TLS-enabled database </p> </li> <li> <p> RS101525 - Cluster provides wrong number of database connections on Grafana </p> </li> <li> <p> RS104028 - Fix the self-signed certificate script: error generating certificates with multiple FQDNs </p> </li> <li> <p> RS87920 - Proxy log is full of the warning message β€œFailed to check status of running child syncer process 0 : No child processesβ€œ </p> </li> <li> <p> RS99916 - Fixed the UI log to include the names of LDAP users at login </p> </li> <li> <p> RS84273 - When an LDAP user with a Redis <code> admin </code> role viewed the log in the UI, they received <code> db_viewer </code> permissions instead of <code> admin </code> , which limited log visibility </p> </li> <li> <p> RS62552 - Fixed database authentication failures for LDAP users when the password contains the <code> % </code> character </p> </li> </ul> <h2 id="version-changes"> Version changes </h2> <h3 id="breaking-changes"> Breaking changes </h3> <ul> <li> <p> Differences when using the <code> UNWATCH </code> command within a <code> MULTI </code> command sequence: </p> <ul> <li> <p> Redis Enterprise: <code> UNWATCH </code> is not allowed within a <code> MULTI </code> command sequence and returns an error. </p> </li> <li> <p> OSS: <code> UNWATCH </code> is allowed within a <code> MULTI </code> sequence but has no effect. </p> </li> </ul> </li> <li> <p> When sending a <code> PUBSUB SHARDNUMSUB </code> command in OSS Cluster mode in Redis Enterprise, Redis Enterprise checks the hash slots of the requested channels. Redis Enterprise responds with a <code> CROSSSLOT </code> error if the channels don’t hash to the same slot, or a <code> MOVED </code> error if the channels hash to a different node. </p> </li> </ul> <h3 id="redis-72-breaking-changes"> Redis 7.2 breaking changes </h3> <p> When new major versions of open source Redis change existing commands, upgrading your database to a new version can potentially break some functionality. Before you upgrade, make sure to read the provided list of breaking changes that affect Redis Enterprise and update any applications that connect to your database to handle these changes. </p> <p> Confirm your Redis database version ( <code> redis_version </code> ) using the admin console or run the following <a href="/docs/latest/commands/info/"> <code> INFO </code> </a> command via <a href="/docs/latest/operate/rs/references/cli-utilities/redis-cli/"> <code> redis-cli </code> </a> : </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ redis-cli -p &lt;port&gt; INFO </span></span><span class="line"><span class="cl"><span class="s2">"# Server </span></span></span><span class="line"><span class="cl"><span class="s2">redis_version:7.0.8 </span></span></span><span class="line"><span class="cl"><span class="s2">..."</span> </span></span></code></pre> </div> <h4 id="breaking-changes-from-version-62"> Breaking changes from version 6.2 </h4> <p> Upgrading to open source Redis version 7.2 from version 6.2 introduces the following potentially breaking changes to Redis Enterprise. </p> <h5 id="programmability"> Programmability </h5> <ul> <li> <p> Lua scripts no longer have access to the <code> print() </code> function ( <a href="https://github.com/redis/redis/pull/10651"> #10651 </a> ) - The <code> print </code> function was removed from Lua because it can potentially cause the Redis processes to get stuck (if no one reads from stdout). Users should use redis.log. An alternative is to override the <code> print </code> implementation and print the message to the log file. </p> </li> <li> <p> Block <a href="/docs/latest/commands/pfcount/"> <code> PFCOUNT </code> </a> and <a href="/docs/latest/commands/publish/"> <code> PUBLISH </code> </a> in read-only scripts (*_RO commands, <code> no-writes </code> ) ( <a href="https://github.com/redis/redis/pull/10744"> #10744 </a> ) - Consider <code> PFCOUNT </code> and <code> PUBLISH </code> as write commands in scripts, in addition to <code> EVAL </code> ; meaning: </p> <ul> <li> They can never be used in scripts with shebang ( <code> #! </code> ) and no <code> no-writes </code> flag </li> <li> They are blocked in <code> EVAL_RO </code> and <code> _RO </code> variants, (even in scripts without shebang ( <code> #! </code> ) flags) </li> <li> Allow <code> no-write </code> scripts in EVAL (not just in EVAL_RO), even during <code> CLIENT PAUSE WRITE </code> </li> </ul> </li> <li> <p> Hide the <code> may_replicate </code> flag from the <a href="/docs/latest/commands/command/"> <code> COMMAND </code> </a> command response ( <a href="https://github.com/redis/redis/pull/10744"> #10744 </a> ) - As part of the change to treat <code> may_replicate </code> commands <code> PFCOUNT </code> and <code> PUBLISH </code> as write commands in scripts, in addition to <code> EVAL </code> , the <code> may_replicate </code> flag has been removed from the <code> COMMAND </code> response. </p> </li> <li> <p> Time sampling is now frozen during command execution and scripts ( <a href="https://github.com/redis/redis/pull/10300"> #10300 </a> ). While a command or script is running, the keys used by the command or script will not expire. This breaks any script that uses a loop to wait for a key to expire. </p> </li> <li> <p> Blocked commands in scripts now work the same way as when they are used in <a href="/docs/latest/develop/interact/transactions/"> transactions </a> ( <a href="https://github.com/redis/redis/pull/11568"> #11568 </a> ). </p> </li> </ul> <h5 id="error-handling"> Error handling </h5> <ul> <li> <p> Rephrased some error responses about invalid commands or arguments ( <a href="https://github.com/redis/redis/pull/10612"> #10612 </a> ) - </p> <ul> <li> Error response for unknown command introduced a case change ( <code> Unknown </code> to <code> unknown </code> ) </li> <li> Errors for module commands extended to cover subcommands, updated syntax to match Redis Server syntax </li> <li> Arity errors for module commands introduce a case change ( <code> Wrong </code> to <code> wrong </code> ); will consider full command name </li> </ul> </li> <li> <p> Corrected error codes returned from <a href="/docs/latest/commands/eval/"> <code> EVAL </code> </a> scripts ( <a href="https://github.com/redis/redis/pull/10218"> #10218 </a> , <a href="https://github.com/redis/redis/pull/10329"> #10329 </a> ). </p> <p> These examples show changes in behavior: </p> <div class="highlight"> <pre class="chroma"><code class="language-diff" data-lang="diff"><span class="line"><span class="cl"> 1: config set maxmemory 1 </span></span><span class="line"><span class="cl"> 2: +OK </span></span><span class="line"><span class="cl"> 3: eval "return redis.call('set','x','y')" 0 </span></span><span class="line"><span class="cl"><span class="gd">- 4: -ERR Error running script (call to 71e6319f97b0fe8bdfa1c5df3ce4489946dda479): @user_script:1: @user_script: 1: -OOM command not allowed when used memory &gt; 'maxmemory'. </span></span></span><span class="line"><span class="cl"><span class="gd"></span><span class="gi">+ 4: -ERR Error running script (call to 71e6319f97b0fe8bdfa1c5df3ce4489946dda479): @user_script:1: OOM command not allowed when used memory &gt; 'maxmemory'. </span></span></span><span class="line"><span class="cl"><span class="gi"></span> 5: eval "return redis.pcall('set','x','y')" 0 </span></span><span class="line"><span class="cl"><span class="gd">- 6: -@user_script: 1: -OOM command not allowed when used memory &gt; 'maxmemory'. </span></span></span><span class="line"><span class="cl"><span class="gd"></span><span class="gi">+ 6: -OOM command not allowed when used memory &gt; 'maxmemory'. </span></span></span><span class="line"><span class="cl"><span class="gi"></span> 7: eval "return redis.call('select',99)" 0 </span></span><span class="line"><span class="cl"> 8: -ERR Error running script (call to 4ad5abfc50bbccb484223905f9a16f09cd043ba8): @user_script:1: ERR DB index is out of range </span></span><span class="line"><span class="cl"> 9: eval "return redis.pcall('select',99)" 0 </span></span><span class="line"><span class="cl"> 10: -ERR DB index is out of range </span></span><span class="line"><span class="cl"> 11: eval_ro "return redis.call('set','x','y')" 0 </span></span><span class="line"><span class="cl"><span class="gd">-12: -ERR Error running script (call to 71e6319f97b0fe8bdfa1c5df3ce4489946dda479): @user_script:1: @user_script: 1: Write commands are not allowed from read-only scripts. </span></span></span><span class="line"><span class="cl"><span class="gd"></span><span class="gi">+12: -ERR Error running script (call to 71e6319f97b0fe8bdfa1c5df3ce4489946dda479): @user_script:1: ERR Write commands are not allowed from read-only scripts. </span></span></span><span class="line"><span class="cl"><span class="gi"></span> 13: eval_ro "return redis.pcall('set','x','y')" 0 </span></span><span class="line"><span class="cl"><span class="gd">-14: -@user_script: 1: Write commands are not allowed from read-only scripts. </span></span></span><span class="line"><span class="cl"><span class="gd"></span><span class="gi">+14: -ERR Write commands are not allowed from read-only scripts. </span></span></span></code></pre> </div> </li> <li> <p> <a href="/docs/latest/commands/zpopmin/"> <code> ZPOPMIN </code> </a> / <a href="/docs/latest/commands/zpopmax/"> <code> ZPOPMAX </code> </a> used to produce wrong replies when count is 0 with non-zset <a href="https://github.com/redis/redis/pull/9711"> #9711 </a> ): </p> <ul> <li> <code> ZPOPMIN </code> / <code> ZPOPMAX </code> used to produce an <code> (empty array) </code> when <code> key </code> was not a sorted set and the optional <code> count </code> argument was set to <code> 0 </code> and now produces a <code> WRONGTYPE </code> error response instead. </li> <li> The optional <code> count </code> argument must be positive. A negative value produces a <code> value is out of range </code> error. </li> </ul> <p> These examples show changes in behavior: </p> <div class="highlight"> <pre class="chroma"><code class="language-diff" data-lang="diff"><span class="line"><span class="cl"> 1: zadd myzset 1 "one" </span></span><span class="line"><span class="cl"> 2: (integer) 1 </span></span><span class="line"><span class="cl"> 3: zadd myzset 2 "two" </span></span><span class="line"><span class="cl"> 4: (integer) 1 </span></span><span class="line"><span class="cl"> 5: zadd myzset 3 "three" </span></span><span class="line"><span class="cl"> 6: (integer) 1 </span></span><span class="line"><span class="cl"> 7: zpopmin myzset -1 </span></span><span class="line"><span class="cl"><span class="gd">- 8: (empty array) </span></span></span><span class="line"><span class="cl"><span class="gd"></span><span class="gi">+ 8: (error) ERR value is out of range, must be positive </span></span></span><span class="line"><span class="cl"><span class="gi"></span> 9: 127.0.0.1:6379&gt; set foo bar </span></span><span class="line"><span class="cl"> 10: OK </span></span><span class="line"><span class="cl"> 11: zpopmin foo 0 </span></span><span class="line"><span class="cl"><span class="gd">-12: (empty array) </span></span></span><span class="line"><span class="cl"><span class="gd"></span><span class="gi">+12: (error) WRONGTYPE Operation against a key holding the wrong kind of value </span></span></span></code></pre> </div> </li> <li> <p> <a href="/docs/latest/commands/lpop/"> <code> LPOP </code> </a> / <a href="/docs/latest/commands/rpop/"> <code> RPOP </code> </a> with count against a nonexistent list returns a null array instead of <code> (nil) </code> ( <a href="https://github.com/redis/redis/pull/10095"> #10095 </a> ). This change was backported to 6.2. </p> </li> <li> <p> <a href="/docs/latest/commands/lpop/"> <code> LPOP </code> </a> / <a href="/docs/latest/commands/rpop/"> <code> RPOP </code> </a> used to produce <code> (nil) </code> when count is 0, now produces a null array ( <a href="https://github.com/redis/redis/pull/9692"> #9692 </a> ). This change was backported to 6.2. </p> </li> <li> <p> <a href="/docs/latest/commands/xclaim/"> <code> XCLAIM </code> </a> / <a href="/docs/latest/commands/xautoclaim/"> <code> XAUTOCLAIM </code> </a> skips deleted entries instead of replying with <code> nil </code> and deletes them from the pending entry list ( <a href="https://github.com/redis/redis/pull/10227"> #10227 </a> ) - <code> XCLAIM </code> / <code> XAUTOCLAIM </code> now behaves in the following way: </p> <ul> <li> If you try to claim a deleted entry, it is deleted from the pending entry list (PEL) where it is found (as well as the group PEL). Therefore, such an entry is not claimed, just cleared from PEL (because it doesn't exist in the stream anyway). </li> <li> Because deleted entries are not claimed, <code> X[AUTO]CLAIM </code> does not return "nil" instead of an entry. </li> <li> Added an array of all the deleted stream IDs to <code> XAUTOCLAIM </code> response. </li> </ul> </li> <li> <p> A blocked stream command that is released when a key no longer exists returns a different error code ( <a href="https://github.com/redis/redis/pull/11012"> #11012 </a> ). </p> <ul> <li> For newly unblocked streams, lists, and zsets, the old implementation returned <code> UNBLOCKED </code> when the stream key was deleted or overwritten with a different type. Now, errors will be the same as if the command was processed after the effect. </li> </ul> </li> <li> <p> ACL errors have been unified across Redis. ( <a href="https://github.com/redis/redis/pull/11160"> #11160 </a> ) </p> <ul> <li> When using <a href="/docs/latest/develop/reference/modules/modules-api-ref/#redismodule_call"> RedisModule_Call </a> module API function, ACL errors return <code> -NOPERM </code> instead of <code> -ERR </code> </li> </ul> </li> <li> <p> <a href="/docs/latest/commands/xreadgroup/"> <code> XREADGROUP </code> </a> and <a href="/docs/latest/commands/xautoclaim/"> <code> XAUTOCLAIM </code> </a> create a consumer regardless of whether it was able to perform reading or claiming ( <a href="https://github.com/redis/redis/pull/11012"> #11012 </a> ). </p> </li> <li> <p> Any float that is Not a Number will return <code> nan </code> ( <a href="https://github.com/redis/redis/pull/11597"> #11597 </a> ). </p> </li> </ul> <h5 id="acls"> ACLs </h5> <ul> <li> <p> <a href="/docs/latest/commands/acl-getuser/"> <code> ACL GETUSER </code> </a> reply now uses ACL syntax for <code> keys </code> and <code> channels </code> ( <a href="https://github.com/redis/redis/pull/9974"> #9974 </a> ). <code> ACL GETUSER </code> now uses the ACL DSL (Domain Specific Language) for keys and channels. </p> <p> These examples show changes in behavior: </p> <div class="highlight"> <pre class="chroma"><code class="language-diff" data-lang="diff"><span class="line"><span class="cl"> 1: acl setuser foo off resetchannels &amp;channel1 -@all +get </span></span><span class="line"><span class="cl"> 2: OK </span></span><span class="line"><span class="cl"> 3: acl getuser foo </span></span><span class="line"><span class="cl"> 4: 1) "flags" </span></span><span class="line"><span class="cl"> 5: 2) 1) "off" </span></span><span class="line"><span class="cl"> 6: 3) "passwords" </span></span><span class="line"><span class="cl"> 7: 4) (empty array) </span></span><span class="line"><span class="cl"> 8: 5) "commands" </span></span><span class="line"><span class="cl"> 9: 6) "-@all +get" </span></span><span class="line"><span class="cl"> 10: 7) "keys" </span></span><span class="line"><span class="cl"><span class="gd">-11: 8) (empty array) </span></span></span><span class="line"><span class="cl"><span class="gd"></span><span class="gi">+11: 8) "" </span></span></span><span class="line"><span class="cl"><span class="gi"></span> 12: 9)"channels" </span></span><span class="line"><span class="cl"><span class="gd">-13 10) 1) "channel1" </span></span></span><span class="line"><span class="cl"><span class="gd"></span><span class="gi">+13 10) "&amp;channel1" </span></span></span></code></pre> </div> </li> <li> <p> <a href="/docs/latest/commands/sort/"> <code> SORT </code> </a> / <a href="/docs/latest/commands/sort_ro/"> <code> SORT_RO </code> </a> commands reject key access patterns in <code> GET </code> and <code> BY </code> if the ACL doesn't grant the command full keyspace access ( <a href="https://github.com/redis/redis/pull/10340"> #10340 </a> ) - The <code> sort </code> and <code> sort_ro </code> commands can access external keys via <code> GET </code> and <code> BY </code> . In order to make sure the user cannot violate the authorization ACL rules, Redis 7 will reject external keys access patterns unless ACL allows <code> SORT </code> full access to all keys. For backwards compatibility, <code> SORT </code> with <code> GET </code> / <code> BY </code> keeps working, but if ACL has restrictions to certain keys, the use of these features will result in a permission denied error. </p> <p> These examples show changes in behavior: </p> <pre tabindex="0"><code>USER FOO (+sort ~* ~mylist) #FOO&gt; sort mylist by w* get v* - is O.K since ~* provides full key access </code></pre> <pre tabindex="0"><code>USER FOO (+sort %R~* ~mylist) #FOO&gt; sort mylist by w* get v* - is O.K since %R~* provides full key READ access** </code></pre> <pre tabindex="0"><code>USER FOO (+sort %W~* ~mylist) #FOO&gt; sort mylist by w* get v* - will now fail since $W~* only provides full key WRITE access </code></pre> <pre tabindex="0"><code>USER FOO (+sort ~v* ~mylist) #FOO&gt; sort mylist by w* get v* - will now fail since ~v* only provides partial key access </code></pre> </li> <li> <p> Fix ACL category for <a href="/docs/latest/commands/select/"> <code> SELECT </code> </a> , [ <code> WAIT </code> ](/docs/latest/commands/wait/, <a href="/docs/latest/commands/role/"> <code> ROLE </code> </a> [ <code> LASTSAVE </code> ](/docs/latest/commands/lastsave/, [ <code> READONLY </code> ](/docs/latest/commands/readonly/, [ <code> READWRITE </code> ](/docs/latest/commands/readwrite/, [ <code> ASKING </code> ](/docs/latest/commands/asking/, <a href="https://github.com/redis/redis/pull/9208"> #9208 </a> ): </p> <ul> <li> <p> <code> SELECT </code> and <code> WAIT </code> have been recategorized from <code> @keyspace </code> to <code> @connection </code> </p> </li> <li> <p> <code> ROLE </code> , <code> LASTSAVE </code> have been categorized as <code> @admin </code> and <code> @dangerous </code> </p> </li> <li> <p> <code> ASKING </code> , <code> READONLY </code> , <code> READWRITE </code> have also been assigned the <code> @connection </code> category and removed from <code> @keyspace </code> </p> </li> <li> <p> Command categories are explained in <a href="/docs/latest/operate/oss_and_stack/management/security/acl/#command-categories"> ACL documentation </a> </p> </li> <li> <p> When a blocked client is being unblocked, checks for ACLs and OOM condition checks are now re-evaluated ( <a href="https://github.com/redis/redis/pull/11012"> #11012 </a> ). </p> <ul> <li> If the ACL rules have changed since the command was executed, the command might fail after the client is unblocked. </li> </ul> </li> </ul> </li> </ul> <h5 id="command-introspection-stats-and-configuration"> Command introspection, stats, and configuration </h5> <ul> <li> <p> <a href="/docs/latest/commands/command/"> <code> COMMAND </code> </a> reply drops <code> random </code> and <code> sort-for-scripts </code> flags, which are now part of <a href="/docs/latest/develop/reference/command-tips/"> command tips </a> ( <a href="https://github.com/redis/redis/pull/10104"> #10104 </a> ) - The <code> random </code> flag was replaced with the <code> nondeterministic_output </code> tip; the <code> sort-for-scripts </code> flag was replaced by the <code> nondeterministic_output_order </code> tip </p> </li> <li> <p> <a href="/docs/latest/commands/info/"> <code> INFO </code> </a> <code> commandstats </code> now shows the stats per sub-command ( <a href="https://github.com/redis/redis/pull/9504"> #9504 </a> ) For example, while previous versions would provide a single entry for all command usage, in Redis 7, each sub command is reported separately: </p> <ul> <li> <p> Redis 6.2: </p> <pre tabindex="0"><code>cmdstat_acl:calls=4,usec=279,usec_per_call=69.75,rejected_calls=0,failed_calls=2 </code></pre> </li> <li> <p> Redis 7: </p> <pre tabindex="0"><code>cmdstat_acl|list:calls=1,usec=4994,usec_per_call=4994.00,rejected_calls=0,failed_calls=0 cmdstat_acl|setuser:calls=2,usec=16409,usec_per_call=8204.50,rejected_calls=0,failed_calls=0 cmdstat_acl|deluser:calls=1,usec=774,usec_per_call=774.00,rejected_calls=0,failed_calls=0 cmdstat_acl|getuser:calls=1,usec=6044,usec_per_call=6044.00,rejected_calls=0,failed_calls=0 </code></pre> </li> </ul> </li> <li> <p> <a href="/docs/latest/commands/config-rewrite/"> <code> CONFIG REWRITE </code> </a> , <a href="/docs/latest/commands/config-resetstat/"> <code> CONFIG RESETSTAT </code> </a> , and most <a href="/docs/latest/commands/config-set/"> <code> CONFIG SET </code> </a> commands are now allowed during loading ( <a href="https://github.com/redis/redis/pull/9878"> #9878 </a> ) </p> </li> <li> <p> When running <a href="/docs/latest/commands/xinfo-consumers/"> <code> XINFO CONSUMERS </code> </a> , the <code> idle </code> time now shows the number of milliseconds that have passed since the last attempted interaction, and the <code> inactive </code> time shows the number of milliseconds since the last successful interaction ( <a href="https://github.com/redis/redis/pull/11099"> #11099 </a> ) </p> <ul> <li> Previously, <code> idle </code> time showed the number of milliseconds that passed since the last successful interaction and there was no <code> inactive </code> time. </li> </ul> </li> <li> <p> Command stats are only updated when the command executes ( <a href="https://github.com/redis/redis/pull/11012"> #11012 </a> ). </p> <ul> <li> Previously, the command stats were updated even if a command was blocked. The command stats are now updated only if and when the command is executed. </li> </ul> </li> </ul> <h4 id="client-prerequisites-for-redis-72-upgrade"> Client prerequisites for Redis 7.2 upgrade </h4> <p> The Redis clients <a href="https://redis.uptrace.dev/"> Go-Redis </a> version 9 and <a href="https://redis.github.io/lettuce/"> Lettuce </a> versions 6 and later use RESP3 by default. If you use either client to run Redis Stack commands, you should set the client's protocol version to RESP2 before upgrading your database to Redis version 7.2 to prevent potential application issues due to RESP3 breaking changes. </p> <p> For applications using Go-Redis v9.0.5 or later, set the protocol version to RESP2: </p> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="nx">client</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"&lt;database_endpoint&gt;"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Protocol</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span> <span class="c1">// Pin the protocol version </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="p">})</span> </span></span></code></pre> </div> <p> To set the protocol version to RESP2 with Lettuce v6 or later: </p> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">io.lettuce.core.*</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">io.lettuce.core.api.*</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">io.lettuce.core.protocol.ProtocolVersion</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1">// ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">RedisClient</span> <span class="n">client</span> <span class="o">=</span> <span class="n">RedisClient</span><span class="o">.</span><span class="na">create</span><span class="o">(</span><span class="s">"&lt;database_endpoint&gt;"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"><span class="n">client</span><span class="o">.</span><span class="na">setOptions</span><span class="o">(</span><span class="n">ClientOptions</span><span class="o">.</span><span class="na">builder</span><span class="o">()</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">protocolVersion</span><span class="o">(</span><span class="n">ProtocolVersion</span><span class="o">.</span><span class="na">RESP2</span><span class="o">)</span> <span class="c1">// Pin the protocol version </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="o">.</span><span class="na">build</span><span class="o">());</span> </span></span><span class="line"><span class="cl"><span class="c1">// ... </span></span></span></code></pre> </div> <p> If you are using <a href="https://github.com/redis-developer/lettucemod/"> LettuceMod </a> , you need to upgrade to <a href="https://github.com/redis-developer/lettucemod/releases/tag/v3.6.0"> v3.6.0 </a> . </p> <h3 id="deprecations"> Deprecations </h3> <h4 id="command-deprecations"> Command deprecations </h4> <ul> <li> <p> <a href="/docs/latest/commands/cluster-slots/"> <code> CLUSTER SLOTS </code> </a> is deprecated as of Redis 7.0 </p> </li> <li> <p> <a href="/docs/latest/commands/json.resp"> <code> JSON.RESP </code> </a> is deprecated as of Redis Stack 7.2. </p> </li> <li> <p> <a href="/docs/latest/commands/quit/"> <code> QUIT </code> </a> is deprecated as of Redis 7.2 </p> </li> </ul> <h4 id="api-deprecations"> API deprecations </h4> <p> Fields deprecated as of Redis Enterprise v4.3.3: </p> <ul> <li> <p> <code> smtp_use_tls </code> (replaced with <code> smtp_tls_mode </code> ) </p> </li> <li> <p> <code> dns_address_master </code> </p> </li> <li> <p> <code> endpoint_node </code> </p> </li> <li> <p> <code> endpoint_ip </code> </p> </li> <li> <p> <code> public_addr </code> (replaced with <code> external_addr </code> ) </p> </li> </ul> <p> Fields deprecated as of Redis Enterprise v4.4.2: </p> <ul> <li> <code> default_shards_overbooking </code> (replaced with <code> shards_overbooking </code> ) </li> </ul> <p> Fields deprecated as of Redis Enterprise v6.4.2: </p> <ul> <li> <p> <code> use_ipv6 </code> (replaced with <code> use_external_ipv6 </code> ) </p> </li> <li> <p> <code> redis_cleanup_job_settings </code> (replaced with <code> persistence_cleanup_scan_interval </code> ) </p> </li> </ul> <p> Fields deprecated as of Redis Enterprise v5.0.1: </p> <ul> <li> <p> <code> bdb_high_syncer_lag </code> (replaced with <code> replica_src_high_syncer_lag </code> and <code> crdt_src_high_syncer_lag </code> ) </p> </li> <li> <p> <code> bdb_syncer_connection_error </code> </p> </li> <li> <p> <code> bdb_syncer_general_error </code> </p> </li> <li> <p> <code> sync_sources </code> (replaced with <code> replica_sources </code> and <code> crdt_sources </code> ) </p> </li> <li> <p> <code> sync </code> (replaced with <code> replica_sync </code> and <code> crdt_sync </code> ) </p> </li> <li> <p> <code> ssl </code> (replaced with <code> tls_mode </code> ) </p> </li> </ul> <p> Fields deprecated as of Redis Enterprise v7.2.4: </p> <ul> <li> <p> <code> node.bigstore_driver </code> (replaced with <code> cluster.bigstore_driver </code> ) </p> </li> <li> <p> <code> auth_method </code> </p> </li> <li> <p> <code> authentication_redis_pass </code> (replaced with multiple passwords feature in version 6.0.X) </p> </li> <li> <p> <code> slave_ha </code> cluster policy </p> </li> </ul> <p> Other deprecated fields: </p> <ul> <li> <p> <code> import/rdb_url </code> (deprecated as of Redis Enterprise v4.X) </p> </li> <li> <p> <code> logrotate_dir </code> (to be replaced with <code> logrotate_config </code> or removed) </p> </li> </ul> <p> Deprecated CLI commands: </p> <ul> <li> <p> <code> rlutil change_master </code> (deprecated as of Redis Enterprise v6.2.18, replaced with <code> rladmin change_master </code> ) </p> </li> <li> <p> <code> rlutil reserved_ports </code> (deprecated as of Redis Enterprise v7.2, replaced with <code> rladmin cluster config reserved_ports </code> ) </p> </li> </ul> <p> REST API requests deprecated as of Redis Enterprise v7.2: </p> <ul> <li> <p> <code> POST /v1/modules </code> (replaced with <code> POST /v2/modules </code> ) </p> </li> <li> <p> <code> DELETE /v1/modules </code> (replaced with <code> DELETE /v2/modules </code> ) </p> </li> </ul> <h4 id="access-control-deprecations"> Access control deprecations </h4> <ul> <li> <p> The following predefined roles and Redis ACLs are no longer available for new Redis Enterprise Software version 7.2.4 clusters: </p> <ul> <li> <p> Custom roles (not management roles): Cluster Member, Cluster Viewer, DB Member, DB Viewer, None. </p> </li> <li> <p> Redis ACLs: Not Dangerous and Read Only. </p> </li> </ul> </li> <li> <p> In upcoming maintenance releases, the deprecated roles and ACLs will be removed automatically when you upgrade to Redis Enterprise Software version 7.2.4, unless they are associated with any users or databases in the cluster. </p> </li> <li> <p> A deprecation notice for SASL-based LDAP was included in <a href="/docs/latest/operate/rs/release-notes/rs-6-2-4-august-2021/#deprecation-notices"> previous Redis Enterprise Software release notes </a> . When you upgrade to Redis Enterprise Software version 7.2.4, all existing "external" users (previously used to support SASL-based LDAP) will be removed. </p> </li> </ul> <h4 id="legacy-ui"> Legacy UI </h4> <p> With the release of the new Cluster Manager UI, the legacy UI is considered deprecated and will eventually be phased out. New functionality will only be implemented in the new Cluster Manager UI, and the old UI will no longer be maintained except for critical bug fixes. </p> <h4 id="redisgraph"> RedisGraph </h4> <p> Redis has announced the end of life for RedisGraph. Redis will continue to support all RedisGraph customers, including releasing patch versions until January 31, 2025. </p> <p> See the <a href="https://redis.com/blog/redisgraph-eol/"> RedisGraph end-of-life announcement </a> for more details. </p> <h4 id="rhel-and-centos-70-79"> RHEL and CentOS 7.0-7.9 </h4> <p> Support for RHEL and CentOS 7.0-7.9 is considered deprecated and will be removed in a future release. </p> <h4 id="oracle-linux-7"> Oracle Linux 7 </h4> <p> Oracle Linux 7 support is considered deprecated and will be removed in a future release. </p> <h4 id="amazon-linux-1"> Amazon Linux 1 </h4> <p> Amazon Linux 1 support is considered deprecated and will be removed in a future release. </p> <h4 id="ubuntu-1604"> Ubuntu 16.04 </h4> <p> The deprecation of Ubuntu 16.04 was announced in the <a href="/docs/latest/operate/rs/release-notes/rs-6-4-2-releases/#deprecations"> Redis Enterprise Software 6.4.2 release notes </a> . As of Redis Enterprise Software 7.2.4, Ubuntu 16.04 is no longer supported. </p> <h4 id="rc4-encryption-cipher"> RC4 encryption cipher </h4> <p> The RC4 encryption cipher is considered deprecated in favor of stronger ciphers. Support for RC4 by the <a href="/docs/latest/operate/rs/databases/durability-ha/discovery-service/"> discovery service </a> will be removed in a future release. </p> <h4 id="3des-encryption-cipher"> 3DES encryption cipher </h4> <p> The 3DES encryption cipher is considered deprecated in favor of stronger ciphers like AES. Please verify that all clients, apps, and connections support the AES cipher. Support for 3DES will be removed in a future release. Certain operating systems, such as RHEL 8, have already removed support for 3DES. Redis Enterprise Software cannot support cipher suites that are not supported by the underlying operating system. </p> <h4 id="tls-10-and-tls-11"> TLS 1.0 and TLS 1.1 </h4> <p> TLS 1.0 and TLS 1.1 connections are considered deprecated in favor of TLS 1.2 or later. Please verify that all clients, apps, and connections support TLS 1.2. Support for the earlier protocols will be removed in a future release. Certain operating systems, such as RHEL 8, have already removed support for the earlier protocols. Redis Enterprise Software cannot support connection protocols that are not supported by the underlying operating system. </p> <h3 id="upcoming-changes"> Upcoming changes </h3> <h4 id="prepare-for-restrictive-pubsub-permissions"> Prepare for restrictive pub/sub permissions </h4> <p> Redis database version 6.2 introduced pub/sub ACL rules that determine which <a href="/docs/latest/develop/interact/pubsub/"> pub/sub channels </a> a user can access. </p> <p> The configuration option <code> acl-pubsub-default </code> , added in Redis Enterprise Software version 6.4.2, determines the cluster-wide default level of access for all pub/sub channels. Redis Enterprise Software uses the following pub/sub permissions by default: </p> <ul> <li> <p> For versions 6.4.2 and 7.2, <code> acl-pubsub-default </code> is permissive ( <code> allchannels </code> or <code> &amp;* </code> ) by default to accommodate earlier Redis versions. </p> </li> <li> <p> In future versions, <code> acl-pubsub-default </code> will change to restrictive ( <code> resetchannels </code> ). Restrictive permissions block all pub/sub channels by default, unless explicitly permitted by an ACL rule. </p> </li> </ul> <p> If you use ACLs and pub/sub channels, you should review your databases and ACL settings and plan to transition your cluster to restrictive pub/sub permissions in preparation for future Redis Enterprise Software releases. </p> <p> When you change the cluster's default pub/sub permissions to restrictive, <code> &amp;* </code> is added to the <strong> Full Access </strong> ACL. Before you make this change, consider the following: </p> <ul> <li> <p> Because pub/sub ACL syntax was added in Redis 6.2, you can't associate the <strong> Full Access </strong> ACL with database versions 6.0 or lower after this change. </p> </li> <li> <p> The <strong> Full Access </strong> ACL is not reverted if you change <code> acl-pubsub-default </code> to permissive again. </p> </li> <li> <p> Every database with the default user enabled uses the <strong> Full Access </strong> ACL. </p> </li> </ul> <p> To secure pub/sub channels and prepare your cluster for future Redis Enterprise Software releases that default to restrictive pub/sub permissions: </p> <ol> <li> <p> Upgrade Redis databases: </p> <ul> <li> <p> For Redis Enterprise Software version 6.4.2, upgrade all databases in the cluster to Redis DB version 6.2. </p> </li> <li> <p> For Redis Enterprise Software version 7.2.4, upgrade all databases in the cluster to Redis DB version 7.2 or 6.2. </p> </li> </ul> </li> <li> <p> Create or update ACLs with permissions for specific channels using the <code> resetchannels &amp;channel </code> format. </p> </li> <li> <p> Associate the ACLs with relevant databases. </p> </li> <li> <p> Set default pub/sub permissions ( <code> acl-pubsub-default </code> ) to restrictive. See <a href="#change-default-pubsub-permissions"> Change default pub/sub permissions </a> for details. </p> </li> <li> <p> If any issues occur, you can temporarily change the default pub/sub setting back to permissive. Resolve any problematic ACLs before making pub/sub permissions restrictive again. </p> </li> </ol> <h4 id="upcoming-command-request-and-reponse-changes"> Upcoming command request and reponse changes </h4> <p> Open source Redis version 7.2 changes the request and response policies for several commands. Because the GA release of Redis Enterprise version 7.2 does not include these policy changes, commands might behave differently from open source Redis. However, these changes will be included in a future Redis Enterprise maintenance release: </p> <ul> <li> <p> <a href="/docs/latest/commands/randomkey/"> <code> RANDOMKEY </code> </a> and <a href="/docs/latest/commands/scan/"> <code> SCAN </code> </a> will change from no response policy to a <code> SPECIAL </code> response policy. </p> </li> <li> <p> <a href="/docs/latest/commands/msetnx/"> <code> MSETNX </code> </a> currently has a <code> MULTI_SHARD </code> request policy and <code> AGG_MIN </code> response policy. Both will change to no policy. </p> </li> </ul> <p> For more information about request and response policies, see <a href="/docs/latest/develop/reference/command-tips/"> Redis command tips </a> . </p> <h3 id="supported-platforms"> Supported platforms </h3> <p> The following table provides a snapshot of supported platforms as of this Redis Enterprise Software release. See the <a href="/docs/latest/operate/rs/references/supported-platforms/"> supported platforms reference </a> for more details about operating system compatibility. </p> <p> <span title="Check mark icon"> βœ… </span> Supported – The platform is supported for this version of Redis Enterprise Software. </p> <p> <span title="Warning icon"> ⚠️ </span> Deprecated – The platform is still supported for this version of Redis Enterprise Software, but support will be removed in a future release. </p> <p> <span title="X icon"> ❌ </span> End of life – Platform support ended in this version of Redis Enterprise Software. </p> <table> <thead> <tr> <th> Redis Enterprise </th> <th> 7.2.4 </th> <th> 6.4.2 </th> <th> 6.2.18 </th> <th> 6.2.12 </th> <th> 6.2.10 </th> <th> 6.2.8 </th> <th> 6.2.4 </th> </tr> </thead> <tbody> <tr> <td> <strong> Ubuntu </strong> <sup> <a href="#table-note-1"> 1 </a> </sup> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> 20.04 </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> <sup> <a href="#table-note-6"> 6 </a> </sup> </td> <td> – </td> <td> – </td> <td> – </td> <td> – </td> <td> – </td> </tr> <tr> <td> 18.04 </td> <td> <span title="Deprecated"> ⚠️ </span> </td> <td> <span title="Supported"> <span title="Supported"> βœ… </span> </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> </tr> <tr> <td> 16.04 </td> <td> <span title="End of life"> ❌ </span> </td> <td> <span title="Deprecated"> ⚠️ </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> </tr> <tr> <td> <strong> RHEL &amp; CentOS </strong> <sup> <a href="#table-note-2"> 2 </a> </sup> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> 8.8 </td> <td> <span title="Supported"> βœ… </span> </td> <td> – </td> <td> – </td> <td> – </td> <td> – </td> <td> – </td> <td> – </td> </tr> <tr> <td> 8.7 </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> – </td> <td> – </td> <td> – </td> <td> – </td> <td> – </td> </tr> <tr> <td> 8.5-8.6 </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> – </td> <td> – </td> </tr> <tr> <td> 8.0-8.4 </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> – </td> </tr> <tr> <td> 7.0-7.9 </td> <td> <span title="Deprecated"> ⚠️ </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> </tr> <tr> <td> <strong> Oracle Linux </strong> <sup> <a href="#table-note-3"> 3 </a> </sup> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> 8 </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> – </td> <td> – </td> </tr> <tr> <td> 7 </td> <td> <span title="Deprecated"> ⚠️ </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> </tr> <tr> <td> <strong> Rocky Linux </strong> <sup> <a href="#table-note-3"> 3 </a> </sup> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> 8 </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> – </td> <td> – </td> <td> – </td> <td> – </td> </tr> <tr> <td> <strong> Amazon Linux </strong> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> 2 </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> <sup> <a href="#table-note-7"> 7 </a> </sup> </td> <td> – </td> <td> – </td> <td> – </td> <td> – </td> <td> – </td> </tr> <tr> <td> 1 </td> <td> <span title="Deprecated"> ⚠️ </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> </tr> <tr> <td> <strong> Docker </strong> <sup> <a href="#table-note-4"> 4 </a> </sup> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> </tr> <tr> <td> <strong> Kubernetes </strong> <sup> <a href="#table-note-5"> 5 </a> </sup> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> </tr> </tbody> </table> <ol> <li> <p> <a name="table-note-1" style="display: block; height: 80px; margin-top: -80px;"> </a> The server version of Ubuntu is recommended for production installations. The desktop version is only recommended for development deployments. </p> </li> <li> <p> <a name="table-note-2" style="display: block; height: 80px; margin-top: -80px;"> </a> RHEL and CentOS deployments require OpenSSL 1.0.2 and <a href="/docs/latest/operate/rs/installing-upgrading/configuring/centos-rhel-firewall/"> firewall configuration </a> . </p> </li> <li> <p> <a name="table-note-3" style="display: block; height: 80px; margin-top: -80px;"> </a> Based on the corresponding RHEL version. </p> </li> <li> <p> <a name="table-note-4" style="display: block; height: 80px; margin-top: -80px;"> </a> <a href="/docs/latest/operate/rs/installing-upgrading/quickstarts/docker-quickstart/"> Docker images </a> of Redis Enterprise Software are certified for development and testing only. </p> </li> <li> <p> <a name="table-note-5" style="display: block; height: 80px; margin-top: -80px;"> </a> See the <a href="/docs/latest/operate/kubernetes/"> Redis Enterprise for Kubernetes documentation </a> . </p> </li> <li> <p> <a name="table-note-6" style="display: block; height: 80px; margin-top: -80px;"> </a> Ubuntu 20.04 support was added in Redis Enterprise Software <a href="/docs/latest/operate/rs/release-notes/rs-6-4-2-releases/rs-6-4-2-43/"> 6.4.2-43 </a> . </p> </li> <li> <p> <a name="table-note-7" style="display: block; height: 80px; margin-top: -80px;"> </a> A release candidate for Amazon Linux 2 support was added in Redis Enterprise Software <a href="/docs/latest/operate/rs/release-notes/rs-6-4-2-releases/rs-6-4-2-61/"> 6.4.2-61 </a> . Official support for Amazon Linux 2 was added in Redis Enterprise Software <a href="/docs/latest/operate/rs/release-notes/rs-6-4-2-releases/rs-6-4-2-69/"> 6.4.2-69 </a> . </p> </li> </ol> <h2 id="downloads"> Downloads </h2> <p> The following table shows the MD5 checksums for the available packages: </p> <table> <thead> <tr> <th> Package </th> <th> MD5 checksum (7.2.4-52 August release) </th> </tr> </thead> <tbody> <tr> <td> Ubuntu 18 </td> <td> 7c7e465c8e129a03ee9f585137b2a1d9 </td> </tr> <tr> <td> Ubuntu 20 </td> <td> 631f27311b19806955fde012953ff9c9 </td> </tr> <tr> <td> RedHat Enterprise Linux (RHEL) 7 <br/> Oracle Enterprise Linux (OL) 7 </td> <td> ae76798b1b7243313b4f4cba6ede88d7 </td> </tr> <tr> <td> RedHat Enterprise Linux (RHEL) 8 <br/> Oracle Enterprise Linux (OL) 8 <br/> Rocky Enterprise Linux </td> <td> 48936b25aefa2921d38aea84ad06134d </td> </tr> <tr> <td> Amazon Linux 2 </td> <td> 3e8180d7a9ebc3784ab6080234edefd5 </td> </tr> </tbody> </table> <h2 id="known-issues"> Known issues </h2> <h4 id="legacy-ui-known-issues"> Legacy UI known issues </h4> <p> When using the legacy UI, you cannot update and save your changes on the <strong> settings &gt; preferences </strong> tab even though these settings are visible. This issue will be fixed in the next maintenance release. </p> <p> As a workaround, use the new Cluster Manager UI to update these settings from the <strong> Cluster &gt; Security &gt; Preferences </strong> tab. </p> <h4 id="pubsub-channel-acl-limitations"> Pub/sub channel ACL limitations </h4> <p> In Redis Enterprise Software version 6.4.2, you could use <code> &amp;channel </code> syntax in Redis ACL rules to allow access to specific pub/sub channels even when default pub/sub permissions were permissive ( <code> &amp;allchannels </code> or <code> &amp;* </code> ), allowing all channels by default. However, <code> &amp;allchannels &amp;channel </code> is not valid syntax. </p> <p> As of Redis Enterprise Software version 7.2.4, you cannot create Redis ACLs with this combination of rules. You can only use <code> &amp;channel </code> to allow access to specific channels if the default pub/sub permissions are restrictive ( <code> resetchannels </code> ). </p> <p> Associating an ACL that contains the invalid syntax <nobr> <code> &amp;allchannels &amp;channel </code> </nobr> (created before version 7.2) with a user and database might leave the database in a pending state, unable to function. </p> <p> To prevent this issue: </p> <ol> <li> <p> Review all existing ACL rules. </p> </li> <li> <p> For each rule containing <code> &amp;channel </code> , either: </p> <ul> <li> <p> Add the <code> resetchannels </code> prefix to restrict access to all channels by default. </p> </li> <li> <p> Delete the rule if not needed. </p> </li> </ul> </li> </ol> <h2 id="known-limitations"> Known limitations </h2> <h4 id="command-limitations"> Command limitations </h4> <ul> <li> <p> <a href="/docs/latest/commands/client-no-touch/"> <code> CLIENT NO-TOUCH </code> </a> might not run correctly in the following cases: </p> <ul> <li> <p> The Redis database version is earlier than 7.2.0. </p> </li> <li> <p> The <code> CLIENT NO-TOUCH </code> command is forbidden by ACL rules. </p> </li> </ul> <p> Before sending this command, clients should verify the database version is 7.2.0 or later and that using this command is allowed. </p> </li> <li> <p> You cannot use <a href="/docs/latest/commands/sunsubscribe/"> <code> SUNSUBSCRIBE </code> </a> to unsubscribe from a shard channel if the regex changed while subscribed. </p> </li> <li> <p> Using <a href="/docs/latest/commands/xreadgroup/"> <code> XREADGROUP BLOCK </code> </a> with <code> &gt; </code> to return all new streams will cause the Redis database to freeze until the shard is restarted. ( <a href="https://github.com/redis/redis/pull/12301"> #12031 </a> ) </p> </li> <li> <p> Because a rejected command does not record the duration for command stats, an error will appear after it is reprocessed that will cause the Redis database to freeze until the shard is restarted. ( <a href="https://github.com/redis/redis/pull/12247"> #12247 </a> ) </p> </li> </ul> <h4 id="modules-cannot-load-in-oracle-linux-7--8"> Modules cannot load in Oracle Linux 7 &amp; 8 </h4> <p> Databases hosted on Oracle Linux 7 &amp; 8 cannot load modules. </p> <p> As a temporary workaround, you can change the node's <code> os_name </code> in the Cluster Configuration Store (CCS): </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">ccs-cli hset node:&lt;ID&gt; os_name rhel </span></span></code></pre> </div> <h4 id="cluster-recovery-with-manually-uploaded-modules"> Cluster recovery with manually uploaded modules </h4> <p> For clusters containing databases with manually uploaded modules, <a href="/docs/latest/operate/rs/clusters/cluster-recovery/"> cluster recovery </a> requires an extra step. </p> <p> After installing Redis Enterprise Software on the cluster nodes, upload compatible modules to <code> modulesdir </code> ( <code> /opt/redislabs/lib/modules </code> )Β before continuing the recovery process. </p> <p> This limitation will be removed in a future maintenance release. </p> <h2 id="security"> Security </h2> <h4 id="open-source-redis-security-fixes-compatibility"> Open source Redis security fixes compatibility </h4> <p> As part of Redis's commitment to security, Redis Enterprise Software implements the latest <a href="https://github.com/redis/redis/releases"> security fixes </a> available with <a href="https://github.com/redis/redis"> open source Redis </a> . Redis Enterprise has already included the fixes for the relevant CVEs. </p> <p> Some CVEs announced for open source Redis do not affect Redis Enterprise due to different or additional functionality available in Redis Enterprise that is not available in open source Redis. </p> <p> Redis Enterprise 7.2.4-52 supports open source Redis 7.2, 6.2, and 6.0. Below is the list of open source Redis CVEs fixed by version. </p> <p> Redis 7.2.0 includes all of the CVE fixes from previous versions. </p> <p> Redis 7.0.x: </p> <ul> <li> <p> (CVE-2023-36824) Extracting key names from a command and a list of arguments may, in some cases, trigger a heap overflow and result in reading random heap memory, heap corruption, and potentially remote code execution. Specifically: using <code> COMMAND GETKEYS* </code> and validation of key names in ACL rules. (Redis 7.0.12) </p> </li> <li> <p> (CVE-2023-28856) Authenticated users can use the <code> HINCRBYFLOAT </code> command to create an invalid hash field that will crash Redis on access. (Redis 7.0.11) </p> </li> <li> <p> (CVE-2023-28425) Specially crafted <code> MSETNX </code> command can lead to assertion and denial-of-service. (Redis 7.0.10) </p> </li> <li> <p> (CVE-2023-25155) Specially crafted <code> SRANDMEMBER </code> , <code> ZRANDMEMBER </code> , and <code> HRANDFIELD </code> commands can trigger an integer overflow, resulting in a runtime assertion and termination of the Redis server process. (Redis 7.0.9) </p> </li> <li> <p> (CVE-2023-22458) Integer overflow in the Redis <code> HRANDFIELD </code> and <code> ZRANDMEMBER </code> commands can lead to denial-of-service. (Redis 7.0.8) </p> </li> <li> <p> (CVE-2022-36021) String matching commands (like <code> SCAN </code> or <code> KEYS </code> ) with a specially crafted pattern to trigger a denial-of-service attack on Redis, causing it to hang and consume 100% CPU time. (Redis 7.0.9) </p> </li> <li> <p> (CVE-2022-35977) Integer overflow in the Redis <code> SETRANGE </code> and <code> SORT </code> / <code> SORT_RO </code> commands can drive Redis to OOM panic. (Redis 7.0.8) </p> </li> <li> <p> (CVE-2022-35951) Executing an <code> XAUTOCLAIM </code> command on a stream key in a specific state, with a specially crafted <code> COUNT </code> argument, may cause an integer overflow, a subsequent heap overflow, and potentially lead to remote code execution. The problem affects Redis versions 7.0.0 or newer. (Redis 7.0.5) </p> </li> <li> <p> (CVE-2022-31144) A specially crafted <code> XAUTOCLAIM </code> command on a stream key in a specific state may result in heap overflow and potentially remote code execution. The problem affects Redis versions 7.0.0 or newer. (Redis 7.0.4) </p> </li> <li> <p> (CVE-2022-24834) A specially crafted Lua script executing in Redis can trigger a heap overflow in the cjson and cmsgpack libraries, and result in heap corruption and potentially remote code execution. The problem exists in all versions of Redis with Lua scripting support, starting from 2.6, and affects only authenticated and authorized users. (Redis 7.0.12) </p> </li> <li> <p> (CVE-2022-24736) An attacker attempting to load a specially crafted Lua script can cause NULL pointer dereference which will result in a crash of the <code> redis-server </code> process. This issue affects all versions of Redis. (Redis 7.0.0) </p> </li> <li> <p> (CVE-2022-24735) By exploiting weaknesses in the Lua script execution environment, an attacker with access to Redis can inject Lua code that will execute with the (potentially higher) privileges of another Redis user. (Redis 7.0.0) </p> </li> </ul> <p> Redis 6.2.x: </p> <ul> <li> <p> (CVE-2023-28856) Authenticated users can use the <code> HINCRBYFLOAT </code> command to create an invalid hash field that will crash Redis on access. (Redis 6.2.12) </p> </li> <li> <p> (CVE-2023-25155) Specially crafted <code> SRANDMEMBER </code> , <code> ZRANDMEMBER </code> , and <code> HRANDFIELD </code> commands can trigger an integer overflow, resulting in a runtime assertion and termination of the Redis server process. (Redis 6.2.11) </p> </li> <li> <p> (CVE-2023-22458) Integer overflow in the Redis <code> HRANDFIELD </code> and <code> ZRANDMEMBER </code> commands can lead to denial-of-service. (Redis 6.2.9) </p> </li> <li> <p> (CVE-2022-36021) String matching commands (like <code> SCAN </code> or <code> KEYS </code> ) with a specially crafted pattern to trigger a denial-of-service attack on Redis, causing it to hang and consume 100% CPU time. (Redis 6.2.11) </p> </li> <li> <p> (CVE-2022-35977) Integer overflow in the Redis <code> SETRANGE </code> and <code> SORT </code> / <code> SORT_RO </code> commands can drive Redis to OOM panic. (Redis 6.2.9) </p> </li> <li> <p> (CVE-2022-24834) A specially crafted Lua script executing in Redis can trigger a heap overflow in the cjson and cmsgpack libraries, and result in heap corruption and potentially remote code execution. The problem exists in all versions of Redis with Lua scripting support, starting from 2.6, and affects only authenticated and authorized users. (Redis 6.2.13) </p> </li> <li> <p> (CVE-2022-24736) An attacker attempting to load a specially crafted Lua script can cause NULL pointer dereference which will result in a crash of the <code> redis-server </code> process. This issue affects all versions of Redis. (Redis 6.2.7) </p> </li> <li> <p> (CVE-2022-24735) By exploiting weaknesses in the Lua script execution environment, an attacker with access to Redis can inject Lua code that will execute with the (potentially higher) privileges of another Redis user. (Redis 6.2.7) </p> </li> <li> <p> (CVE-2021-41099) Integer to heap buffer overflow handling certain string commands and network payloads, when <code> proto-max-bulk-len </code> is manually configured to a non-default, very large value. (Redis 6.2.6) </p> </li> <li> <p> (CVE-2021-32762) Integer to heap buffer overflow issue in <code> redis-cli </code> and <code> redis-sentinel </code> parsing large multi-bulk replies on some older and less common platforms. (Redis 6.2.6) </p> </li> <li> <p> (CVE-2021-32761) An integer overflow bug in Redis version 2.2 or newer can be exploited using the <code> BITFIELD </code> command to corrupt the heap and potentially result with remote code execution. (Redis 6.2.5) </p> </li> <li> <p> (CVE-2021-32687) Integer to heap buffer overflow with intsets, when <code> set-max-intset-entries </code> is manually configured to a non-default, very large value. (Redis 6.2.6) </p> </li> <li> <p> (CVE-2021-32675) Denial Of Service when processing RESP request payloads with a large number of elements on many connections. (Redis 6.2.6) </p> </li> <li> <p> (CVE-2021-32672) Random heap reading issue with Lua Debugger. (Redis 6.2.6) </p> </li> <li> <p> (CVE-2021-32628) Integer to heap buffer overflow handling ziplist-encoded data types, when configuring a large, non-default value for <code> hash-max-ziplist-entries </code> , <code> hash-max-ziplist-value </code> , <code> zset-max-ziplist-entries </code> or <code> zset-max-ziplist-value </code> . (Redis 6.2.6) </p> </li> <li> <p> (CVE-2021-32627) Integer to heap buffer overflow issue with streams, when configuring a non-default, large value for <code> proto-max-bulk-len </code> and <code> client-query-buffer-limit </code> . (Redis 6.2.6) </p> </li> <li> <p> (CVE-2021-32626) Specially crafted Lua scripts may result with Heap buffer overflow. (Redis 6.2.6) </p> </li> <li> <p> (CVE-2021-32625) An integer overflow bug in Redis version 6.0 or newer can be exploited using the STRALGO LCS command to corrupt the heap and potentially result with remote code execution. This is a result of an incomplete fix by CVE-2021-29477. (Redis 6.2.4) </p> </li> <li> <p> (CVE-2021-29478) An integer overflow bug in Redis 6.2 could be exploited to corrupt the heap and potentially result with remote code execution. The vulnerability involves changing the default set-max-intset-entries configuration value, creating a large set key that consists of integer values and using the COPY command to duplicate it. The integer overflow bug exists in all versions of Redis starting with 2.6, where it could result with a corrupted RDB or DUMP payload, but not exploited through COPY (which did not exist before 6.2). (Redis 6.2.3) </p> </li> <li> <p> (CVE-2021-29477) An integer overflow bug in Redis version 6.0 or newer could be exploited using the STRALGO LCS command to corrupt the heap and potentially result in remote code execution. The integer overflow bug exists in all versions of Redis starting with 6.0. (Redis 6.2.3) </p> </li> </ul> <p> Redis 6.0.x: </p> <ul> <li> <p> (CVE-2022-24834) A specially crafted Lua script executing in Redis can trigger a heap overflow in the cjson and cmsgpack libraries, and result in heap corruption and potentially remote code execution. The problem exists in all versions of Redis with Lua scripting support, starting from 2.6, and affects only authenticated and authorized users. (Redis 6.0.20) </p> </li> <li> <p> (CVE-2023-28856) Authenticated users can use the <code> HINCRBYFLOAT </code> command to create an invalid hash field that will crash Redis on access. (Redis 6.0.19) </p> </li> <li> <p> (CVE-2023-25155) Specially crafted <code> SRANDMEMBER </code> , <code> ZRANDMEMBER </code> , and <code> HRANDFIELD </code> commands can trigger an integer overflow, resulting in a runtime assertion and termination of the Redis server process. (Redis 6.0.18) </p> </li> <li> <p> (CVE-2022-36021) String matching commands (like <code> SCAN </code> or <code> KEYS </code> ) with a specially crafted pattern to trigger a denial-of-service attack on Redis, causing it to hang and consume 100% CPU time. (Redis 6.0.18) </p> </li> <li> <p> (CVE-2022-35977) Integer overflow in the Redis <code> SETRANGE </code> and <code> SORT </code> / <code> SORT_RO </code> commands can drive Redis to OOM panic. (Redis 6.0.17) </p> </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/release-notes/rs-7-2-4-releases/rs-7-2-4-52/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/requests/cluster/certificates/rotate/.html
<section class="prose w-full py-12 max-w-none"> <h1> Rotate cluster certificates requests </h1> <p class="text-lg -mt-5 mb-10"> Rotate cluster certificates requests </p> <table> <thead> <tr> <th> Method </th> <th> Path </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="#post-cluster-certificates-rotate"> POST </a> </td> <td> <code> /v1/cluster/certificates/rotate </code> </td> <td> Regenerate all internal cluster certificates </td> </tr> </tbody> </table> <h2 id="post-cluster-certificates-rotate"> Rotate cluster certificates </h2> <pre><code>POST /v1/cluster/certificates/rotate </code></pre> <p> Regenerates all <em> internal </em> cluster certificates. </p> <p> The certificate rotation will be performed on all nodes within the cluster. If "name" is provided, only rotate the specified certificate on all nodes within the cluster. </p> <h3 id="post-request"> Request </h3> <h4 id="example-http-request"> Example HTTP request </h4> <pre><code>POST /cluster/certificates/rotate </code></pre> <h4 id="request-headers"> Request headers </h4> <table> <thead> <tr> <th> Key </th> <th> Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> Host </td> <td> cnm.cluster.fqdn </td> <td> Domain name </td> </tr> <tr> <td> Accept </td> <td> application/json </td> <td> Accepted media type </td> </tr> </tbody> </table> <h3 id="post-response"> Response </h3> <p> Responds with a <code> 200 OK </code> status code if the internal certificates successfully rotate across the entire cluster. </p> <h3 id="post-status-codes"> Status codes </h3> <table> <thead> <tr> <th> Code </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1"> 200 OK </a> </td> <td> No error </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1"> 400 Bad Request </a> </td> <td> Failed, not all nodes have been updated. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.4"> 403 Forbidden </a> </td> <td> Unsupported internal certificate rotation. </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/requests/cluster/certificates/rotate/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/lcs/.html
<section class="prose w-full py-12"> <h1 class="command-name"> LCS </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">LCS key1 key2 [LEN] [IDX] [MINMATCHLENΒ min-match-len] [WITHMATCHLEN]</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 7.0.0 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(N*M) where N and M are the lengths of s1 and s2, respectively </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @read </code> <span class="mr-1 last:hidden"> , </span> <code> @string </code> <span class="mr-1 last:hidden"> , </span> <code> @slow </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> The LCS command implements the longest common subsequence algorithm. Note that this is different than the longest common string algorithm, since matching characters in the string does not need to be contiguous. </p> <p> For instance the LCS between "foo" and "fao" is "fo", since scanning the two strings from left to right, the longest common set of characters is composed of the first "f" and then the "o". </p> <p> LCS is very useful in order to evaluate how similar two strings are. Strings can represent many things. For instance if two strings are DNA sequences, the LCS will provide a measure of similarity between the two DNA sequences. If the strings represent some text edited by some user, the LCS could represent how different the new text is compared to the old one, and so forth. </p> <p> Note that this algorithm runs in <code> O(N*M) </code> time, where N is the length of the first string and M is the length of the second string. So either spin a different Redis instance in order to run this algorithm, or make sure to run it against very small strings. </p> <pre tabindex="0"><code>&gt; MSET key1 ohmytext key2 mynewtext OK &gt; LCS key1 key2 "mytext" </code></pre> <p> Sometimes we need just the length of the match: </p> <pre tabindex="0"><code>&gt; LCS key1 key2 LEN (integer) 6 </code></pre> <p> However what is often very useful, is to know the match position in each strings: </p> <pre tabindex="0"><code>&gt; LCS key1 key2 IDX 1) "matches" 2) 1) 1) 1) (integer) 4 2) (integer) 7 2) 1) (integer) 5 2) (integer) 8 2) 1) 1) (integer) 2 2) (integer) 3 2) 1) (integer) 0 2) (integer) 1 3) "len" 4) (integer) 6 </code></pre> <p> Matches are produced from the last one to the first one, since this is how the algorithm works, and it more efficient to emit things in the same order. The above array means that the first match (second element of the array) is between positions 2-3 of the first string and 0-1 of the second. Then there is another match between 4-7 and 5-8. </p> <p> To restrict the list of matches to the ones of a given minimal length: </p> <pre tabindex="0"><code>&gt; LCS key1 key2 IDX MINMATCHLEN 4 1) "matches" 2) 1) 1) 1) (integer) 4 2) (integer) 7 2) 1) (integer) 5 2) (integer) 8 3) "len" 4) (integer) 6 </code></pre> <p> Finally to also have the match len: </p> <pre tabindex="0"><code>&gt; LCS key1 key2 IDX MINMATCHLEN 4 WITHMATCHLEN 1) "matches" 2) 1) 1) 1) (integer) 4 2) (integer) 7 2) 1) (integer) 5 2) (integer) 8 3) (integer) 4 3) "len" 4) (integer) 6 </code></pre> <h2 id="resp2-reply"> RESP2 Reply </h2> <p> One of the following: </p> <ul> <li> <a href="../../develop/reference/protocol-spec#bulk-strings"> Bulk string reply </a> : the longest common subsequence. </li> <li> <a href="../../develop/reference/protocol-spec#integers"> Integer reply </a> : the length of the longest common subsequence when <em> LEN </em> is given. </li> <li> <a href="../../develop/reference/protocol-spec#arrays"> Array reply </a> : an array with the LCS length and all the ranges in both the strings when <em> IDX </em> is given. </li> </ul> <h2 id="resp3-reply"> RESP3 Reply </h2> <p> One of the following: </p> <ul> <li> <a href="../../develop/reference/protocol-spec#bulk-strings"> Bulk string reply </a> : the longest common subsequence. </li> <li> <a href="../../develop/reference/protocol-spec#integers"> Integer reply </a> : the length of the longest common subsequence when <em> LEN </em> is given. </li> <li> <a href="../../develop/reference/protocol-spec#maps"> Map reply </a> : a map with the LCS length and all the ranges in both the strings when <em> IDX </em> is given. </li> </ul> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/lcs/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/ts.incrby.html
<section class="prose w-full py-12"> <h1 class="command-name"> TS.INCRBY </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">TS.INCRBY key addend [TIMESTAMP timestamp] [RETENTION retentionPeriod] [ENCODING &lt;COMPRESSED|UNCOMPRESSED&gt;] [CHUNK_SIZE size] [DUPLICATE_POLICY policy] [IGNORE ignoreMaxTimediff ignoreMaxValDiff] [LABELS [label value ...]] </pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available in: </dt> <dd class="m-0"> <a href="/docs/stack"> Redis Stack </a> / <a href="/docs/data-types/timeseries"> TimeSeries 1.0.0 </a> </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(M) when M is the amount of compaction rules or O(1) with no compaction </dd> </dl> <p> Increase the value of the sample with the maximum existing timestamp, or create a new sample with a value equal to the value of the sample with the maximum existing timestamp with a given increment </p> <p> <a href="#examples"> Examples </a> </p> <h2 id="required-arguments"> Required arguments </h2> <details open=""> <summary> <code> key </code> </summary> <p> is key name for the time series. </p> </details> <details open=""> <summary> <code> addend </code> </summary> <p> is numeric value of the addend (double). </p> </details> <p> <note> <b> Notes </b> </note> </p> <ul> <li> When specified key does not exist, a new time series is created. </li> <li> You can use this command as a counter or gauge that automatically gets history as a time series. </li> <li> If a policy for handling duplicate samples ( <code> IGNORE </code> ) is defined for this time series - <code> TS.INCRBY </code> operations are affected as well (sample additions/modifications can be filtered). </li> <li> Explicitly adding samples to a compacted time series (using <a href="/docs/latest/commands/ts.add/"> <code> TS.ADD </code> </a> , <a href="/docs/latest/commands/ts.madd/"> <code> TS.MADD </code> </a> , <code> TS.INCRBY </code> , or <a href="/docs/latest/commands/ts.decrby/"> <code> TS.DECRBY </code> </a> ) may result in inconsistencies between the raw and the compacted data. The compaction process may override such samples. <br/> </li> </ul> <h2 id="optional-arguments"> Optional arguments </h2> <details open=""> <summary> <code> TIMESTAMP timestamp </code> </summary> <p> is Unix time (integer, in milliseconds) specifying the sample timestamp or <code> * </code> to set the sample timestamp to the Unix time of the server's clock. </p> <p> Unix time is the number of milliseconds that have elapsed since 00:00:00 UTC on 1 January 1970, the Unix epoch, without adjustments made due to leap seconds. </p> <p> <code> timestamp </code> must be equal to or higher than the maximum existing timestamp. When equal, the value of the sample with the maximum existing timestamp is increased. If it is higher, a new sample with a timestamp set to <code> timestamp </code> is created, and its value is set to the value of the sample with the maximum existing timestamp plus <code> addend </code> . </p> <p> If the time series is empty, the value is set to <code> addend </code> . </p> <p> When not specified, the timestamp is set to the Unix time of the server's clock. </p> </details> <details open=""> <summary> <code> RETENTION retentionPeriod </code> <p> is maximum retention period, compared to the maximum existing timestamp, in milliseconds. </p> <p> Use it only if you are creating a new time series. It is ignored if you are adding samples to an existing time series. See <code> RETENTION </code> in <a href="/docs/latest/commands/ts.create/"> <code> TS.CREATE </code> </a> . </p> </summary> </details> <details open=""> <summary> <code> ENCODING enc </code> </summary> <p> specifies the series sample encoding format. </p> <p> Use it only if you are creating a new time series. It is ignored if you are adding samples to an existing time series. See <code> ENCODING </code> in <a href="/docs/latest/commands/ts.create/"> <code> TS.CREATE </code> </a> . </p> </details> <details open=""> <summary> <code> CHUNK_SIZE size </code> </summary> <p> is memory size, in bytes, allocated for each data chunk. </p> <p> Use it only if you are creating a new time series. It is ignored if you are adding samples to an existing time series. See <code> CHUNK_SIZE </code> in <a href="/docs/latest/commands/ts.create/"> <code> TS.CREATE </code> </a> . </p> </details> <details open=""> <summary> <code> DUPLICATE_POLICY policy </code> </summary> <p> is policy for handling insertion ( <a href="/docs/latest/commands/ts.add/"> <code> TS.ADD </code> </a> and <a href="/docs/latest/commands/ts.madd/"> <code> TS.MADD </code> </a> ) of multiple samples with identical timestamps. </p> <p> Use it only if you are creating a new time series. It is ignored if you are adding samples to an existing time series. See <code> DUPLICATE_POLICY </code> in <a href="/docs/latest/commands/ts.create/"> <code> TS.CREATE </code> </a> . </p> </details> <details open=""> <summary> <code> IGNORE ignoreMaxTimediff ignoreMaxValDiff </code> </summary> <p> is the policy for handling duplicate samples. A new sample is considered a duplicate and is ignored if the following conditions are met: </p> <ul> <li> The time series is not a compaction; </li> <li> The time series' <code> DUPLICATE_POLICY </code> IS <code> LAST </code> ; </li> <li> The sample is added in-order ( <code> timestamp β‰₯ max_timestamp </code> ); </li> <li> The difference of the current timestamp from the previous timestamp ( <code> timestamp - max_timestamp </code> ) is less than or equal to <code> IGNORE_MAX_TIME_DIFF </code> ; </li> <li> The absolute value difference of the current value from the value at the previous maximum timestamp ( <code> abs(value - value_at_max_timestamp </code> ) is less than or equal to <code> IGNORE_MAX_VAL_DIFF </code> . </li> </ul> <p> where <code> max_timestamp </code> is the timestamp of the sample with the largest timestamp in the time series, and <code> value_at_max_timestamp </code> is the value at <code> max_timestamp </code> . </p> <p> When not specified: set to the global <a href="/docs/latest/develop/data-types/timeseries/configuration#ignore_max_time_diff-and-ignore_max_val_diff"> IGNORE_MAX_TIME_DIFF </a> and <a href="/docs/latest/develop/data-types/timeseries/configuration#ignore_max_time_diff-and-ignore_max_val_diff"> IGNORE_MAX_VAL_DIFF </a> , which are, by default, both set to 0. </p> <p> These parameters are used when creating a new time series to set the per-key parameters, and are ignored when called with an existing time series (the existing per-key configuration parameters are used). </p> </details> <details open=""> <summary> <code> LABELS [{label value}...] </code> </summary> <p> is set of label-value pairs that represent metadata labels of the key and serve as a secondary index. </p> <p> Use it only if you are creating a new time series. It is ignored if you are adding samples to an existing time series. See <code> LABELS </code> in <a href="/docs/latest/commands/ts.create/"> <code> TS.CREATE </code> </a> . </p> </details> <p> <note> <b> Notes </b> </note> </p> <ul> <li> You can use this command to create a new time series and add a sample to it in a single command. <code> RETENTION </code> , <code> ENCODING </code> , <code> CHUNK_SIZE </code> , <code> DUPLICATE_POLICY </code> , <code> IGNORE </code> , and <code> LABELS </code> are used only when creating a new time series, and ignored when adding or modifying samples in an existing time series. </li> <li> Setting <code> RETENTION </code> and <code> LABELS </code> introduces additional time complexity. </li> </ul> <h2 id="return-value"> Return value </h2> <p> Returns one of these replies: </p> <ul> <li> <a href="/docs/latest/develop/reference/protocol-spec/#integers"> Integer reply </a> - the timestamp of the upserted sample. If the sample is ignored (See <code> IGNORE </code> in <a href="/docs/latest/commands/ts.create/"> <code> TS.CREATE </code> </a> ), the reply will be the largest timestamp in the time series. </li> <li> [] on error (invalid arguments, wrong key type, etc.), or when <code> timestamp </code> is not equal to or higher than the maximum existing timestamp </li> </ul> <h2 id="examples"> Examples </h2> <details open=""> <summary> <b> Store sum of data from several sources </b> </summary> <p> Suppose you are getting number of orders or total income per minute from several points of sale, and you want to store only the combined value. Call TS.INCRBY for each point-of-sale report. </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379&gt; TS.INCRBY a <span class="m">232</span> TIMESTAMP 1657811829000 // point-of-sale <span class="c1">#1</span> </span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">1657811829000</span> </span></span><span class="line"><span class="cl">127.0.0.1:6379&gt; TS.INCRBY a <span class="m">157</span> TIMESTAMP 1657811829000 // point-of-sale <span class="c1">#2</span> </span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">1657811829000</span> </span></span><span class="line"><span class="cl">127.0.0.1:6379&gt; TS.INCRBY a <span class="m">432</span> TIMESTAMP 1657811829000 // point-of-sale <span class="c1">#3</span> </span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">1657811829000</span></span></span></code></pre> </div> <p> Note that the timestamps must arrive in non-decreasing order. </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379&gt; ts.incrby a <span class="m">100</span> TIMESTAMP <span class="m">50</span> </span></span><span class="line"><span class="cl"><span class="o">(</span>error<span class="o">)</span> TSDB: timestamp must be equal to or higher than the maximum existing timestamp</span></span></code></pre> </div> <p> You can achieve similar results without such protection using <code> TS.ADD key timestamp value ON_DUPLICATE sum </code> . </p> </details> <details open=""> <summary> <b> Count sensor captures </b> </summary> <p> Suppose a sensor ticks whenever a car is passed on a road, and you want to count occurrences. Whenever you get a tick from the sensor you can simply call: </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379&gt; TS.INCRBY a <span class="m">1</span> </span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">1658431553109</span></span></span></code></pre> </div> <p> The timestamp is filled automatically. </p> </details> <h2 id="see-also"> See also </h2> <p> <a href="/docs/latest/commands/ts.decrby/"> <code> TS.DECRBY </code> </a> | <a href="/docs/latest/commands/ts.create/"> <code> TS.CREATE </code> </a> </p> <h2 id="related-topics"> Related topics </h2> <p> <a href="/docs/latest/develop/data-types/timeseries/"> RedisTimeSeries </a> </p> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/ts.incrby/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/bzpopmin/.html
<section class="prose w-full py-12"> <h1 class="command-name"> BZPOPMIN </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">BZPOPMIN key [key ...] timeout</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 5.0.0 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(log(N)) with N being the number of elements in the sorted set. </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @write </code> <span class="mr-1 last:hidden"> , </span> <code> @sortedset </code> <span class="mr-1 last:hidden"> , </span> <code> @fast </code> <span class="mr-1 last:hidden"> , </span> <code> @blocking </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> <code> BZPOPMIN </code> is the blocking variant of the sorted set <a href="/docs/latest/commands/zpopmin/"> <code> ZPOPMIN </code> </a> primitive. </p> <p> It is the blocking version because it blocks the connection when there are no members to pop from any of the given sorted sets. A member with the lowest score is popped from first sorted set that is non-empty, with the given keys being checked in the order that they are given. </p> <p> The <code> timeout </code> argument is interpreted as a double value specifying the maximum number of seconds to block. A timeout of zero can be used to block indefinitely. </p> <p> See the <a href="/commands/blpop"> BLPOP documentation </a> for the exact semantics, since <code> BZPOPMIN </code> is identical to <a href="/docs/latest/commands/blpop/"> <code> BLPOP </code> </a> with the only difference being the data structure being popped from. </p> <h2 id="examples"> Examples </h2> <pre tabindex="0"><code>redis&gt; DEL zset1 zset2 (integer) 0 redis&gt; ZADD zset1 0 a 1 b 2 c (integer) 3 redis&gt; BZPOPMIN zset1 zset2 0 1) "zset1" 2) "a" 3) "0" </code></pre> <h2 id="resp2-reply"> RESP2 Reply </h2> <p> One of the following: </p> <ul> <li> <a href="../../develop/reference/protocol-spec#bulk-strings"> Nil reply </a> : when no element could be popped and the <em> timeout </em> expired. </li> <li> <a href="../../develop/reference/protocol-spec#arrays"> Array reply </a> : the keyname, popped member, and its score. </li> </ul> <h2 id="resp3-reply"> RESP3 Reply </h2> <p> One of the following: </p> <ul> <li> <a href="../../develop/reference/protocol-spec#nulls"> Null reply </a> : when no element could be popped and the <em> timeout </em> expired. </li> <li> <a href="../../develop/reference/protocol-spec#arrays"> Array reply </a> : the keyname, popped member, and its score. </li> </ul> <br/> <h2> History </h2> <ul> <li> Starting with Redis version 6.0.0: <code> timeout </code> is interpreted as a double instead of an integer. </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/bzpopmin/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/7.4/databases/active-active/develop/data-types/hashes/.html
<section class="prose w-full py-12 max-w-none"> <h1> Hashes in an Active-Active databases </h1> <p class="text-lg -mt-5 mb-10"> Information about using hashes with an Active-Active database. </p> <p> Hashes are great for structured data thatΒ contain a map of fields and values. They are used for managing distributed user or app session state, user preferences, form data and so on. Hash fields contain string type and string types operate just like the standard Redis string types when it comes to CRDTs. Fields in hashes can be initialized as a string using HSET or HMSET or can be used to initialize counter types that are numeric integers using HINCRBY or floats using HINCRBYFLOAT. </p> <p> Hashes in Active-Active databases behave the same and maintain additional metadata to achieve an "OR-Set" behavior to handle concurrent conflicting writes. With the OR-Set behavior, writes to add new fields across multiple Active-Active database instances are typically unioned except in cases of conflicts. Conflicting instance writes can happen when an Active-Active database instance deletes a field while the other adds the same field. In this case and observed remove rule is followed. That is, remove can only remove fields it has already seen and in all other cases element add/update wins. </p> <p> Field values behave just like CRDT strings. String values can be types string, counter integer based on the command used for initialization of the field value. See "String Data Type in Active-Active databases" and "String Data Type with Counter Value in Active-Active databases" for more details. </p> <p> Here is an example of an "add wins" case: </p> <table> <thead> <tr> <th style="text-align:right"> <strong> Time </strong> </th> <th style="text-align:center"> <strong> CRDB Instance1 </strong> </th> <th style="text-align:center"> <strong> CRDB Instance2 </strong> </th> </tr> </thead> <tbody> <tr> <td style="text-align:right"> t1 </td> <td style="text-align:center"> HSET key1 field1 β€œa” </td> <td style="text-align:center"> </td> </tr> <tr> <td style="text-align:right"> t2 </td> <td style="text-align:center"> </td> <td style="text-align:center"> HSET key1 field2 β€œb” </td> </tr> <tr> <td style="text-align:right"> t4 </td> <td style="text-align:center"> - Sync - </td> <td style="text-align:center"> - Sync - </td> </tr> <tr> <td style="text-align:right"> t5 </td> <td style="text-align:center"> HGETALL key1 <br/> 1) β€œfield2” <br/> 2) β€œb” <br/> 3) β€œfield1” <br/> 4) β€œa” </td> <td style="text-align:center"> HGETALL key1 <br/> 1) β€œfield2” <br/> 2) β€œb” <br/> 3) β€œfield1” <br/> 4) β€œa” </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/databases/active-active/develop/data-types/hashes/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/acl-save/.html
<section class="prose w-full py-12"> <h1 class="command-name"> ACL SAVE </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">ACL SAVE</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 6.0.0 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(N). Where N is the number of configured users. </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @admin </code> <span class="mr-1 last:hidden"> , </span> <code> @slow </code> <span class="mr-1 last:hidden"> , </span> <code> @dangerous </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> When Redis is configured to use an ACL file (with the <code> aclfile </code> configuration option), this command will save the currently defined ACLs from the server memory to the ACL file. </p> <h2 id="examples"> Examples </h2> <pre tabindex="0"><code>&gt; ACL SAVE +OK &gt; ACL SAVE -ERR There was an error trying to save the ACLs. Please check the server logs for more information </code></pre> <h2 id="resp2resp3-reply"> RESP2/RESP3 Reply </h2> <a href="../../develop/reference/protocol-spec#simple-strings"> Simple string reply </a> : <code> OK </code> . The command may fail with an error for several reasons: if the file cannot be written or if the server is not configured to use an external ACL file. <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/acl-save/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/requests/license/.html
<section class="prose w-full py-12 max-w-none"> <h1> License requests </h1> <p class="text-lg -mt-5 mb-10"> License requests </p> <table> <thead> <tr> <th> Method </th> <th> Path </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="#get-license"> GET </a> </td> <td> <code> /v1/license </code> </td> <td> Get license details </td> </tr> <tr> <td> <a href="#put-license"> PUT </a> </td> <td> <code> /v1/license </code> </td> <td> Update the license </td> </tr> </tbody> </table> <h2 id="get-license"> Get license </h2> <pre><code>GET /v1/license </code></pre> <p> Returns the license details, including license string, expiration, and supported features. </p> <h4 id="required-permissions"> Required permissions </h4> <table> <thead> <tr> <th> Permission name </th> </tr> </thead> <tbody> <tr> <td> <a href="/docs/latest/operate/rs/7.4/references/rest-api/permissions/#view_license"> view_license </a> </td> </tr> </tbody> </table> <h3 id="get-request"> Request </h3> <h4 id="example-http-request"> Example HTTP request </h4> <pre><code>GET /license </code></pre> <h4 id="request-headers"> Request headers </h4> <table> <thead> <tr> <th> Key </th> <th> Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> Host </td> <td> cnm.cluster.fqdn </td> <td> Domain name </td> </tr> <tr> <td> Accept </td> <td> application/json </td> <td> Accepted media type </td> </tr> </tbody> </table> <h3 id="get-response"> Response </h3> <p> Returns a JSON object that contains the license details: </p> <table> <thead> <tr> <th> Name </th> <th> Type/Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> license </td> <td> string </td> <td> License data </td> </tr> <tr> <td> cluster_name </td> <td> string </td> <td> The cluster name (FQDN) </td> </tr> <tr> <td> expired </td> <td> boolean </td> <td> If the cluster key is expired ( <code> true </code> or <code> false </code> ) </td> </tr> <tr> <td> activation_date </td> <td> string </td> <td> The date of the cluster key activation </td> </tr> <tr> <td> expiration_date </td> <td> string </td> <td> The date of the cluster key expiration </td> </tr> <tr> <td> key </td> <td> string </td> <td> License key </td> </tr> <tr> <td> features </td> <td> array of strings </td> <td> Features supported by the cluster </td> </tr> <tr> <td> owner </td> <td> string </td> <td> License owner </td> </tr> <tr> <td> shards_limit </td> <td> integer </td> <td> The total number of shards allowed by the cluster key </td> </tr> <tr> <td> ram_shards_limit </td> <td> integer </td> <td> The number of RAM shards allowed by the cluster key (as of v7.2) </td> </tr> <tr> <td> ram_shards_in_use </td> <td> integer </td> <td> The number of RAM shards in use </td> </tr> <tr> <td> flash_shards_limit </td> <td> integer </td> <td> The number of flash shards (Auto Tiering) allowed by the cluster key (as of v7.2) </td> </tr> <tr> <td> flash_shards_in_use </td> <td> integer </td> <td> The number of flash shards in use </td> </tr> </tbody> </table> <h4 id="example-json-body"> Example JSON body </h4> <div class="highlight"> <pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"license"</span><span class="p">:</span> <span class="s2">"----- LICENSE START -----\\ndi+iK...KniI9\\n----- LICENSE END -----\\n"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"expired"</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"activation_date"</span><span class="p">:</span><span class="s2">"2018-12-31T00:00:00Z"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"expiration_date"</span><span class="p">:</span><span class="s2">"2019-12-31T00:00:00Z"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"ram_shards_in_use"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"ram_shards_limit"</span><span class="p">:</span> <span class="mi">300</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"flash_shards_in_use"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"flash_shards_limit"</span><span class="p">:</span> <span class="mi">100</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"shards_limit"</span><span class="p">:</span> <span class="mi">400</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"features"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"bigstore"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="nt">"owner"</span><span class="p">:</span> <span class="s2">"Redis"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"cluster_name"</span><span class="p">:</span> <span class="s2">"mycluster.local"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"key"</span><span class="p">:</span> <span class="s2">"----- LICENSE START -----\\ndi+iK...KniI9\\n----- LICENSE END -----\\n"</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <h3 id="get-status-codes"> Status codes </h3> <table> <thead> <tr> <th> Code </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1"> 200 OK </a> </td> <td> License is returned in the response body. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5"> 404 Not Found </a> </td> <td> No license is installed. </td> </tr> </tbody> </table> <h2 id="put-license"> Update license </h2> <pre><code>PUT /v1/license </code></pre> <p> Validate and install a new license string. </p> <p> If you do not provide a valid license, the cluster behaves as if the license was deleted. See <a href="/docs/latest/operate/rs/7.4/clusters/configure/license-keys/#expired-cluster-license"> Expired cluster license </a> for a list of available actions and restrictions. </p> <h4 id="required-permissions-1"> Required permissions </h4> <table> <thead> <tr> <th> Permission name </th> </tr> </thead> <tbody> <tr> <td> <a href="/docs/latest/operate/rs/7.4/references/rest-api/permissions/#install_new_license"> install_new_license </a> </td> </tr> </tbody> </table> <h3 id="put-request"> Request </h3> <p> The request must be a JSON object with a single key named "license". </p> <h4 id="example-http-request-1"> Example HTTP request </h4> <pre><code>PUT /license </code></pre> <h4 id="example-json-body-1"> Example JSON body </h4> <div class="highlight"> <pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"license"</span><span class="p">:</span> <span class="s2">"----- LICENSE START -----\ndi+iK...KniI9\n----- LICENSE END -----\n"</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <h4 id="request-headers-1"> Request headers </h4> <table> <thead> <tr> <th> Key </th> <th> Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> Accept </td> <td> application/json </td> <td> Accepted media type </td> </tr> </tbody> </table> <h4 id="request-body"> Request body </h4> <p> Include a JSON object that contains the new <code> license </code> string in the request body. </p> <h3 id="put-response"> Response </h3> <p> Returns an error if the new license is not valid. </p> <h3 id="put-status-codes"> Status codes </h3> <table> <thead> <tr> <th> Code </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1"> 200 OK </a> </td> <td> License installed successfully. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1"> 400 Bad Request </a> </td> <td> Invalid request, either bad JSON object or corrupted license was supplied. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.7"> 406 Not Acceptable </a> </td> <td> License violation. A response body provides more details on the specific cause. </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/requests/license/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/develop/interact/search-and-query/deprecated/payloads/.html
<section class="prose w-full py-12"> <h1> Document payloads </h1> <p class="text-lg -mt-5 mb-10"> Payload support(deprecated) </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Warning: </div> The payload feature is deprecated in 2.0 </div> </div> <p> Usually, Redis Stack stores documents as hashes or JSON. But if you want to access some data for aggregation or scoring functions, Redis can store that data as an inline payload. This will allow us to evaluate the properties of a document for scoring purposes at a very low cost. </p> <p> Since the scoring functions already have access to the DocumentMetaData, which contains document flags and score, Redis can add custom payloads that can be evaluated in run-time. </p> <p> Payloads are NOT indexed and are not treated by the engine in any way. They are simply there for the purpose of evaluating them in query time, and optionally retrieving them. They can be JSON objects, strings, or preferably, if you are interested in fast evaluation, some sort of binary encoded data which is fast to decode. </p> <h2 id="evaluating-payloads-in-query-time"> Evaluating payloads in query time </h2> <p> When implementing a scoring function, the signature of the function exposed is: </p> <div class="highlight"> <pre class="chroma"><code class="language-c" data-lang="c"><span class="line"><span class="cl"><span class="kt">double</span> <span class="p">(</span><span class="o">*</span><span class="n">ScoringFunction</span><span class="p">)(</span><span class="n">DocumentMetadata</span> <span class="o">*</span><span class="n">dmd</span><span class="p">,</span> <span class="n">IndexResult</span> <span class="o">*</span><span class="n">h</span><span class="p">);</span> </span></span></code></pre> </div> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> Currently, scoring functions cannot be dynamically added, and forking the engine and replacing them is required. </div> </div> <p> DocumentMetaData includes a few fields, one of them being the payload. It wraps a simple byte array with arbitrary length: </p> <div class="highlight"> <pre class="chroma"><code class="language-c" data-lang="c"><span class="line"><span class="cl"><span class="k">typedef</span> <span class="k">struct</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">char</span> <span class="o">*</span><span class="n">data</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="kt">uint32_t</span> <span class="n">len</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> <span class="n">DocumentPayload</span><span class="p">;</span> </span></span></code></pre> </div> <p> If no payload was set to the document, it is simply NULL. If it is not, you can go ahead and decode it. It is recommended to encode some metadata about the payload inside it, like a leading version number, etc. </p> <h2 id="retrieving-payloads-from-documents"> Retrieving payloads from documents </h2> <p> When searching, it is possible to request the document payloads from the engine. </p> <p> This is done by adding the keyword <code> WITHPAYLOADS </code> to <a href="/docs/latest/commands/ft.search/"> <code> FT.SEARCH </code> </a> . </p> <p> If <code> WITHPAYLOADS </code> is set, the payloads follow the document id in the returned result. If <code> WITHSCORES </code> is set as well, the payloads follow the scores. </p> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/interact/search-and-query/deprecated/payloads/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/7.4/installing-upgrading/install/.html
<section class="prose w-full py-12 max-w-none"> <h1> Install Redis Enterprise Software </h1> <p class="text-lg -mt-5 mb-10"> Install Redis Enterprise Software on Linux. </p> <p> After you <a href="/docs/latest/operate/rs/7.4/installing-upgrading/install/plan-deployment/"> plan your deployment </a> , <a href="/docs/latest/operate/rs/7.4/installing-upgrading/install/prepare-install/download-install-package/"> download a Redis Enterprise Software installation package </a> , and finish <a href="/docs/latest/operate/rs/7.4/installing-upgrading/install/prepare-install/"> installation preparation </a> : </p> <ol> <li> <p> <a href="/docs/latest/operate/rs/7.4/installing-upgrading/install/install-on-linux/"> Install the Redis Enterprise Software package </a> on one of the nodes in the cluster. </p> </li> <li> <p> Repeat this process for each node in the cluster. </p> </li> </ol> <p> For installation on machines without an internet connection, see <a href="/docs/latest/operate/rs/7.4/installing-upgrading/install/offline-installation/"> Offline installation </a> . </p> <h2 id="permissions-and-access"> Permissions and access </h2> <ul> <li> <p> Redis Enterprise Software installation creates the <code> redislabs:redislabs </code> user and group. </p> <p> Assigning other users to the <code> redislabs </code> group is optional. Users belonging to the <code> redislabs </code> group have permission to read and execute (e.g. use the <code> rladmin </code> status command) but are not allowed to write (or delete) files or directories. </p> </li> <li> <p> Redis Enterprise Software is certified to run with permissions set to <code> 750 </code> , an industry standard. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Warning: </div> Do not reduce permissions to <code> 700 </code> . This configuration has not been tested and is not supported. </div> </div> </li> </ul> <h2 id="more-info-and-options"> More info and options </h2> <p> If you've already installed Redis Enterprise Software, you can also: </p> <ul> <li> <p> <a href="/docs/latest/operate/rs/7.4/installing-upgrading/upgrading/"> Upgrade an existing deployment </a> . </p> </li> <li> <p> <a href="/docs/latest/operate/rs/7.4/installing-upgrading/uninstalling/"> Uninstall an existing deployment </a> . </p> </li> </ul> <p> To learn more about customization and find answers to related questions, see: </p> <ul> <li> <a href="/docs/latest/operate/rs/7.4/installing-upgrading/configuring/centos-rhel-firewall/"> CentOS/RHEL Firewall configuration </a> </li> <li> <a href="/docs/latest/operate/rs/7.4/installing-upgrading/configuring/change-location-socket-files/"> Change socket file location </a> </li> <li> <a href="/docs/latest/operate/rs/7.4/networking/cluster-dns/"> Cluster DNS configuration </a> </li> <li> <a href="/docs/latest/operate/rs/7.4/networking/cluster-lba-setup/"> Cluster load balancer setup </a> </li> <li> <a href="/docs/latest/operate/rs/7.4/installing-upgrading/install/plan-deployment/file-locations/"> File locations </a> </li> <li> <a href="/docs/latest/operate/rs/7.4/installing-upgrading/install/plan-deployment/supported-platforms/"> Supported platforms </a> </li> <li> <a href="/docs/latest/operate/rs/7.4/installing-upgrading/install/manage-installation-questions/"> Manage installation questions </a> </li> <li> <a href="/docs/latest/operate/rs/7.4/networking/mdns/"> mDNS client prerequisites </a> </li> <li> <a href="/docs/latest/operate/rs/7.4/installing-upgrading/install/customize-user-and-group/"> User and group ownership </a> </li> </ul> <h2 id="next-steps"> Next steps </h2> <p> After your cluster is set up with nodes, you can: </p> <ul> <li> <a href="/docs/latest/operate/rs/7.4/security/access-control/create-users/"> Add users </a> to the cluster with specific permissions. To begin, start with <a href="/docs/latest/operate/rs/7.4/security/access-control/"> Access control </a> . </li> <li> <a href="/docs/latest/operate/rs/7.4/databases/create/"> Create databases </a> to use with your applications. </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/installing-upgrading/install/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/latency-histogram/.html
<section class="prose w-full py-12"> <h1 class="command-name"> LATENCY HISTOGRAM </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">LATENCY HISTOGRAM [command [command ...]]</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 7.0.0 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(N) where N is the number of commands with latency information being retrieved. </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @admin </code> <span class="mr-1 last:hidden"> , </span> <code> @slow </code> <span class="mr-1 last:hidden"> , </span> <code> @dangerous </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> <code> LATENCY HISTOGRAM </code> returns a cumulative distribution of commands' latencies in histogram format. </p> <p> By default, all available latency histograms are returned. You can filter the reply by providing specific command names. </p> <p> Each histogram consists of the following fields: </p> <ul> <li> Command name </li> <li> The total calls for that command </li> <li> A map of time buckets: <ul> <li> Each bucket represents a latency range </li> <li> Each bucket covers twice the previous bucket's range </li> <li> Empty buckets are excluded from the reply </li> <li> The tracked latencies are between 1 microsecond and roughly 1 second </li> <li> Everything above 1 second is considered +Inf </li> <li> At max, there will be log2(1,000,000,000)=30 buckets </li> </ul> </li> </ul> <p> This command requires the extended latency monitoring feature to be enabled, which is the default. If you need to enable it, call <code> CONFIG SET latency-tracking yes </code> . </p> <p> To delete the latency histograms' data use the <a href="/docs/latest/commands/config-resetstat/"> <code> CONFIG RESETSTAT </code> </a> command. </p> <h2 id="examples"> Examples </h2> <pre tabindex="0"><code>127.0.0.1:6379&gt; LATENCY HISTOGRAM set 1# "set" =&gt; 1# "calls" =&gt; (integer) 100000 2# "histogram_usec" =&gt; 1# (integer) 1 =&gt; (integer) 99583 2# (integer) 2 =&gt; (integer) 99852 3# (integer) 4 =&gt; (integer) 99914 4# (integer) 8 =&gt; (integer) 99940 5# (integer) 16 =&gt; (integer) 99968 6# (integer) 33 =&gt; (integer) 100000 </code></pre> <h2 id="resp2-reply"> RESP2 Reply </h2> <a href="../../develop/reference/protocol-spec#arrays"> Array reply </a> : a map where each key is a command name, and each value is a map with the total calls, and an inner map of the histogram time buckets. <h2 id="resp3-reply"> RESP3 Reply </h2> <a href="../../develop/reference/protocol-spec#maps"> Map reply </a> : a map where each key is a command name, and each value is a map with the total calls, and an inner map of the histogram time buckets. <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/latency-histogram/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/integrate/write-behind/reference/cli/redis-di-stop/.html
<section class="prose w-full py-12 max-w-none"> <h1> redis-di stop </h1> <p class="text-lg -mt-5 mb-10"> Stops the pipeline </p> <h2 id="usage"> Usage </h2> <pre tabindex="0"><code>Usage: redis-di stop [OPTIONS] </code></pre> <h2 id="options"> Options </h2> <ul> <li> <p> <code> loglevel </code> : </p> <ul> <li> Type: Choice(['DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL']) </li> <li> Default: <code> info </code> </li> <li> Usage: <code> --loglevel -log-level </code> </li> </ul> </li> <li> <p> <code> rdi_host </code> (REQUIRED): </p> <ul> <li> Type: STRING </li> <li> Default: <code> none </code> </li> <li> Usage: <code> --rdi-host </code> </li> </ul> <p> Host/IP of Write-behind Database </p> </li> <li> <p> <code> rdi_port </code> (REQUIRED): </p> <ul> <li> Type: &lt;IntRange 1000&lt;=x&lt;=65535&gt; </li> <li> Default: <code> none </code> </li> <li> Usage: <code> --rdi-port </code> </li> </ul> <p> Port of Write-behind Database </p> </li> <li> <p> <code> rdi_password </code> : </p> <ul> <li> Type: STRING </li> <li> Default: <code> none </code> </li> <li> Usage: <code> --rdi-password </code> </li> </ul> <p> Write-behind Database Password </p> </li> <li> <p> <code> rdi_key </code> : </p> <ul> <li> Type: STRING </li> <li> Default: <code> none </code> </li> <li> Usage: <code> --rdi-key </code> </li> </ul> <p> Private key file to authenticate with </p> </li> <li> <p> <code> rdi_cert </code> : </p> <ul> <li> Type: STRING </li> <li> Default: <code> none </code> </li> <li> Usage: <code> --rdi-cert </code> </li> </ul> <p> Client certificate file to authenticate with </p> </li> <li> <p> <code> rdi_cacert </code> : </p> <ul> <li> Type: STRING </li> <li> Default: <code> none </code> </li> <li> Usage: <code> --rdi-cacert </code> </li> </ul> <p> CA certificate file to verify with </p> </li> <li> <p> <code> rdi_key_password </code> : </p> <ul> <li> Type: STRING </li> <li> Default: <code> none </code> </li> <li> Usage: <code> --rdi-key-password </code> </li> </ul> <p> Password for unlocking an encrypted private key </p> </li> <li> <p> <code> help </code> : </p> <ul> <li> Type: BOOL </li> <li> Default: <code> false </code> </li> <li> Usage: <code> --help </code> </li> </ul> <p> Show this message and exit. </p> </li> </ul> <h2 id="cli-help"> CLI help </h2> <pre tabindex="0"><code>Usage: redis-di stop [OPTIONS] Stops the pipeline Options: -log-level, --loglevel [DEBUG|INFO|WARN|ERROR|CRITICAL] [default: INFO] --rdi-host TEXT Host/IP of Write-behind Database [required] --rdi-port INTEGER RANGE Port of Write-behind Database [1000&lt;=x&lt;=65535; required] --rdi-password TEXT Write-behind Database Password --rdi-key TEXT Private key file to authenticate with --rdi-cert TEXT Client certificate file to authenticate with --rdi-cacert TEXT CA certificate file to verify with --rdi-key-password TEXT Password for unlocking an encrypted private key --help Show this message and exit. </code></pre> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/integrate/write-behind/reference/cli/redis-di-stop/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/databases/active-active/causal-consistency/.html
<section class="prose w-full py-12 max-w-none"> <h1> Enable causal consistency </h1> <p class="text-lg -mt-5 mb-10"> Enable causal consistency in an Active-Active database. </p> <p> When you enable causal consistency in Active-Active databases, the order of operations on a specific key are maintained across all Active-Active database instances. </p> <p> For example, if operations A and B were applied on the same key and the effect of A was observed by the instance that initiated B before B was applied to the key. All instances of an Active-Active database would then observe the effect of A before observing the effect of B. This way, any causal relationship between operations on the same key is also observed and maintained by every replica. </p> <h3 id="enable-causal-consistency"> Enable causal consistency </h3> <p> When you create an Active-Active database, you can enable causal consistency in the Cluster Manager UI: </p> <ol> <li> <p> In the <strong> Participating clusters </strong> section of the <strong> Create Active-Active database </strong> screen, locate <strong> Causal Consistency </strong> : </p> <a href="/docs/latest/images/rs/screenshots/databases/active-active-databases/create-a-a-db-participating-clusters.png" sdata-lightbox="/images/rs/screenshots/databases/active-active-databases/create-a-a-db-participating-clusters.png"> <img alt="The Participating clusters section of the Create Active-Active database screen." src="/docs/latest/images/rs/screenshots/databases/active-active-databases/create-a-a-db-participating-clusters.png"/> </a> </li> <li> <p> Click <strong> Change </strong> to open the <strong> Causal Consistency </strong> dialog. </p> </li> <li> <p> Select <strong> Enabled </strong> : </p> <a href="/docs/latest/images/rs/screenshots/databases/active-active-databases/enable-causal-consistency.png" sdata-lightbox="/images/rs/screenshots/databases/active-active-databases/enable-causal-consistency.png"> <img alt="Enabled is selected in the Causal Consistency dialog." src="/docs/latest/images/rs/screenshots/databases/active-active-databases/enable-causal-consistency.png"/> </a> </li> <li> <p> Click <strong> Change </strong> to confirm your selection. </p> </li> </ol> <p> After database creation, you can only turn causal consistency on or off using the REST API or <code> crdb-cli </code> . The updated setting only affects commands and operations received after the change. </p> <h3 id="causal-consistency-side-effects"> Causal consistency side effects </h3> <p> When the causal consistency option is enabled, each instance maintains the order of operations it received from another instance and relays that information to all other N-2 instances, where N represents the number of instances used by the Active-Active database. </p> <p> As a result, network traffic is increased by a factor of (N-2). The memory consumed by each instance and overall performance are also impacted when causal consistency is activated. </p> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/databases/active-active/causal-consistency/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/integrate/write-behind/reference/cli/redis-di-deploy/.html
<section class="prose w-full py-12 max-w-none"> <h1> redis-di deploy </h1> <p class="text-lg -mt-5 mb-10"> Deploys the Write-behind configurations including target </p> <h2 id="usage"> Usage </h2> <pre tabindex="0"><code>Usage: redis-di deploy [OPTIONS] </code></pre> <h2 id="options"> Options </h2> <ul> <li> <p> <code> loglevel </code> : </p> <ul> <li> Type: Choice(['DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL']) </li> <li> Default: <code> info </code> </li> <li> Usage: <code> --loglevel -log-level </code> </li> </ul> </li> <li> <p> <code> rdi_host </code> (REQUIRED): </p> <ul> <li> Type: STRING </li> <li> Default: <code> none </code> </li> <li> Usage: <code> --rdi-host </code> </li> </ul> <p> Host/IP of Write-behind Database </p> </li> <li> <p> <code> rdi_port </code> (REQUIRED): </p> <ul> <li> Type: &lt;IntRange 1000&lt;=x&lt;=65535&gt; </li> <li> Default: <code> none </code> </li> <li> Usage: <code> --rdi-port </code> </li> </ul> <p> Port of Write-behind Database </p> </li> <li> <p> <code> rdi_password </code> : </p> <ul> <li> Type: STRING </li> <li> Default: <code> none </code> </li> <li> Usage: <code> --rdi-password </code> </li> </ul> <p> Write-behind Database Password </p> </li> <li> <p> <code> rdi_key </code> : </p> <ul> <li> Type: STRING </li> <li> Default: <code> none </code> </li> <li> Usage: <code> --rdi-key </code> </li> </ul> <p> Private key file to authenticate with </p> </li> <li> <p> <code> rdi_cert </code> : </p> <ul> <li> Type: STRING </li> <li> Default: <code> none </code> </li> <li> Usage: <code> --rdi-cert </code> </li> </ul> <p> Client certificate file to authenticate with </p> </li> <li> <p> <code> rdi_cacert </code> : </p> <ul> <li> Type: STRING </li> <li> Default: <code> none </code> </li> <li> Usage: <code> --rdi-cacert </code> </li> </ul> <p> CA certificate file to verify with </p> </li> <li> <p> <code> rdi_key_password </code> : </p> <ul> <li> Type: STRING </li> <li> Default: <code> none </code> </li> <li> Usage: <code> --rdi-key-password </code> </li> </ul> <p> Password for unlocking an encrypted private key </p> </li> <li> <p> <code> directory </code> : </p> <ul> <li> Type: STRING </li> <li> Default: <code> . </code> </li> <li> Usage: <code> --dir </code> </li> </ul> <p> Directory containing Write-behind configuration </p> </li> <li> <p> <code> help </code> : </p> <ul> <li> Type: BOOL </li> <li> Default: <code> false </code> </li> <li> Usage: <code> --help </code> </li> </ul> <p> Show this message and exit. </p> </li> </ul> <h2 id="cli-help"> CLI help </h2> <pre tabindex="0"><code>Usage: redis-di deploy [OPTIONS] Deploys the Write-behind configurations including target Options: -log-level, --loglevel [DEBUG|INFO|WARN|ERROR|CRITICAL] [default: INFO] --rdi-host TEXT Host/IP of Write-behind Database [required] --rdi-port INTEGER RANGE Port of Write-behind Database [1000&lt;=x&lt;=65535; required] --rdi-password TEXT Write-behind Database Password --rdi-key TEXT Private key file to authenticate with --rdi-cert TEXT Client certificate file to authenticate with --rdi-cacert TEXT CA certificate file to verify with --rdi-key-password TEXT Password for unlocking an encrypted private key --dir TEXT Directory containing Write-behind configuration [default: .] --help Show this message and exit. </code></pre> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/integrate/write-behind/reference/cli/redis-di-deploy/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/oss_and_stack/.html
<section class="prose w-full py-12 max-w-none"> <h1> Redis Community Edition and Stack </h1> <p class="text-lg -mt-5 mb-10"> Operate Redis Community Edition and Redis Stack. Redis OSS was renamed Redis Community Edition (CE) with the v7.4 release. </p> <nav> <a href="/docs/latest/operate/oss_and_stack/install/"> Install Redis or Redis Stack </a> <p> How to install your preferred Redis flavor on your target platform </p> <a href="/docs/latest/operate/oss_and_stack/management/"> Manage Redis </a> <p> An administrator's guide to Redis </p> <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/"> Redis Stack and Redis Enterprise </a> <br/> <br/> <a href="/docs/latest/operate/oss_and_stack/reference/"> Reference </a> <p> Redis Community Edition and Redis Stack reference documentation </p> </nav> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/oss_and_stack/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/lindex/.html
<section class="prose w-full py-12"> <h1 class="command-name"> LINDEX </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">LINDEX key index</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 1.0.0 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(N) where N is the number of elements to traverse to get to the element at index. This makes asking for the first or the last element of the list O(1). </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @read </code> <span class="mr-1 last:hidden"> , </span> <code> @list </code> <span class="mr-1 last:hidden"> , </span> <code> @slow </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> Returns the element at index <code> index </code> in the list stored at <code> key </code> . The index is zero-based, so <code> 0 </code> means the first element, <code> 1 </code> the second element and so on. Negative indices can be used to designate elements starting at the tail of the list. Here, <code> -1 </code> means the last element, <code> -2 </code> means the penultimate and so forth. </p> <p> When the value at <code> key </code> is not a list, an error is returned. </p> <h2 id="examples"> Examples </h2> <div class="bg-slate-900 border-b border-slate-700 rounded-t-xl px-4 py-3 w-full flex"> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10Z"> </path> </svg> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M10 2.5L18.6603 17.5L1.33975 17.5L10 2.5Z"> </path> </svg> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M10 2.5L12.0776 7.9322L17.886 8.22949L13.3617 11.8841L14.8738 17.5L10 14.3264L5.1262 17.5L6.63834 11.8841L2.11403 8.22949L7.92238 7.9322L10 2.5Z"> </path> </svg> </div> <form class="redis-cli overflow-y-auto max-h-80"> <pre tabindex="0">redis&gt; LPUSH mylist "World" (integer) 1 redis&gt; LPUSH mylist "Hello" (integer) 2 redis&gt; LINDEX mylist 0 "Hello" redis&gt; LINDEX mylist -1 "World" redis&gt; LINDEX mylist 3 (nil) </pre> <div class="prompt" style=""> <span> redis&gt; </span> <input autocomplete="off" name="prompt" spellcheck="false" type="text"/> </div> </form> <h2 id="resp2-reply"> RESP2 Reply </h2> <p> One of the following: </p> <ul> <li> <a href="../../develop/reference/protocol-spec#bulk-strings"> Nil reply </a> : when <em> index </em> is out of range. </li> <li> <a href="../../develop/reference/protocol-spec#bulk-strings"> Bulk string reply </a> : the requested element. </li> </ul> <h2 id="resp3-reply"> RESP3 Reply </h2> <p> One of the following: </p> <ul> <li> <a href="../../develop/reference/protocol-spec#nulls"> Null reply </a> : when <em> index </em> is out of range. </li> <li> <a href="../../develop/reference/protocol-spec#bulk-strings"> Bulk string reply </a> : the requested element. </li> </ul> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/lindex/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/7.4/clusters/optimize/.html
<section class="prose w-full py-12 max-w-none"> <h1> Optimize clusters </h1> <p class="text-lg -mt-5 mb-10"> Configuration changes and information you can use to optimize your performance and memory usage. </p> <nav> <a href="/docs/latest/operate/rs/7.4/clusters/optimize/memtier-benchmark/"> Benchmarking Redis Enterprise </a> <p> Use the <code> memtier_benchmark </code> tool to perform a performance benchmark of Redis Enterprise Software. </p> <a href="/docs/latest/operate/rs/7.4/clusters/optimize/disk-sizing-heavy-write-scenarios/"> Disk sizing for heavy write scenarios </a> <p> Sizing considerations for persistent disk space for heavy throughput databases. </p> <a href="/docs/latest/operate/rs/7.4/clusters/optimize/optimization/"> Cluster environment optimization </a> <p> Optimize your cluster environments for better performance. </p> <a href="/docs/latest/operate/rs/7.4/clusters/optimize/turn-off-services/"> Turn off services to free system memory </a> <p> Turn off services to free memory and improve performance. </p> <a href="/docs/latest/operate/rs/7.4/clusters/optimize/oss-cluster-api/"> Redis OSS Cluster API </a> <p> Use the Redis OSS Cluster API to improve performance and keep applications current with cluster topology changes. </p> <a href="/docs/latest/operate/rs/7.4/clusters/optimize/wait/"> Use the WAIT command to improve data safety and durability </a> <p> Use the wait command to take full advantage of Redis Enterprise Software's replication-based durability. </p> </nav> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/clusters/optimize/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/7.4/references/cli-utilities/crdb-cli/crdb/delete/.html
<section class="prose w-full py-12 max-w-none"> <h1> crdb-cli crdb delete </h1> <p class="text-lg -mt-5 mb-10"> Deletes an Active-Active database. </p> <p> Deletes an Active-Active database. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">crdb-cli crdb delete --crdb-guid &lt;guid&gt; </span></span><span class="line"><span class="cl"> <span class="o">[</span> --no-wait <span class="o">]</span> </span></span></code></pre> </div> <p> This command is irreversible. If the data in your database is important, back it up before you delete the database. </p> <h3 id="parameters"> Parameters </h3> <table> <thead> <tr> <th> Parameter </th> <th> Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> crdb-guid </td> <td> string </td> <td> The GUID of the database (required) </td> </tr> <tr> <td> no-wait </td> <td> </td> <td> Does not wait for the task to complete </td> </tr> </tbody> </table> <h3 id="returns"> Returns </h3> <p> Returns the task ID of the task that is deleting the database. </p> <p> If <code> --no-wait </code> is specified, the command exits. Otherwise, it will wait for the database to be deleted and return <code> finished </code> . </p> <h3 id="example"> Example </h3> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ crdb-cli crdb delete --crdb-guid db6365b5-8aca-4055-95d8-7eb0105c0b35 </span></span><span class="line"><span class="cl">Task dfe6cacc-88ff-4667-812e-938fd05fe359 created </span></span><span class="line"><span class="cl"> ---&gt; Status changed: queued -&gt; started </span></span><span class="line"><span class="cl"> ---&gt; Status changed: started -&gt; finished </span></span></code></pre> </div> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/references/cli-utilities/crdb-cli/crdb/delete/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/references/cli-utilities/rladmin/cluster/recover/.html
<section class="prose w-full py-12 max-w-none"> <h1> rladmin cluster recover </h1> <p class="text-lg -mt-5 mb-10"> Recovers a cluster from a backup file. </p> <p> Recovers a cluster from a backup file. The default location of the configuration backup file is <code> /var/opt/redislabs/persist/ccs/ccs-redis.rdb </code> . </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin cluster recover </span></span><span class="line"><span class="cl"> filename &lt;recovery filename&gt; </span></span><span class="line"><span class="cl"> <span class="o">[</span> ephemeral_path &lt;path&gt; <span class="o">]</span> </span></span><span class="line"><span class="cl"> <span class="o">[</span> persistent_path &lt;path&gt; <span class="o">]</span> </span></span><span class="line"><span class="cl"> <span class="o">[</span> ccs_persistent_path &lt;path&gt; <span class="o">]</span> </span></span><span class="line"><span class="cl"> <span class="o">[</span> rack_id &lt;ID&gt; <span class="o">]</span> </span></span><span class="line"><span class="cl"> <span class="o">[</span> override_rack_id <span class="o">]</span> </span></span><span class="line"><span class="cl"> <span class="o">[</span> node_uid &lt;number&gt; <span class="o">]</span> </span></span><span class="line"><span class="cl"> <span class="o">[</span> flash_enabled <span class="o">]</span> </span></span><span class="line"><span class="cl"> <span class="o">[</span> flash_path &lt;path&gt; <span class="o">]</span> </span></span><span class="line"><span class="cl"> <span class="o">[</span> addr &lt;IP address&gt; <span class="o">]</span> </span></span><span class="line"><span class="cl"> <span class="o">[</span> external_addr &lt;IP address&gt; <span class="o">]</span> </span></span></code></pre> </div> <h3 id="parameters"> Parameters </h3> <table> <thead> <tr> <th> Parameter </th> <th> Type/Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> addr </td> <td> IP address </td> <td> Sets a node's internal IP address. If not provided, the node sets the address automatically. (optional) </td> </tr> <tr> <td> ccs_persistent_path </td> <td> filepath </td> <td> Path to the location of CCS snapshots (default is the same as persistent_path) (optional) </td> </tr> <tr> <td> external_addr </td> <td> IP address </td> <td> Sets a node's external IP address. If not provided, the node sets the address automatically. (optional) </td> </tr> <tr> <td> ephemeral_path </td> <td> filepath (default:Β /var/opt/redislabs) </td> <td> Path to an ephemeral storage location (optional) </td> </tr> <tr> <td> filename </td> <td> filepath </td> <td> Backup file to use for recovery </td> </tr> <tr> <td> flash_enabled </td> <td> </td> <td> Enables flash storage (optional) </td> </tr> <tr> <td> flash_path </td> <td> filepath (default:Β /var/opt/redislabs/flash) </td> <td> Path to the flash storage location in case the node does not support CAPI (required if flash_enabled) </td> </tr> <tr> <td> node_uid </td> <td> integer (default:Β 1) </td> <td> Specifies which node will recover first and become master (optional) </td> </tr> <tr> <td> override_rack_id </td> <td> </td> <td> Changes to a new rack, specified by <code> rack_id </code> (optional) </td> </tr> <tr> <td> persistent_path </td> <td> filepath </td> <td> Path to the persistent storage location (optional) </td> </tr> <tr> <td> rack_id </td> <td> string </td> <td> Switches to the specified rack (optional) </td> </tr> </tbody> </table> <h3 id="returns"> Returns </h3> <p> Returns <code> ok </code> if the cluster recovered successfully. Otherwise, it returns an error message. </p> <h3 id="example"> Example </h3> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ rladmin cluster recover filename /tmp/persist/ccs/ccs-redis.rdb node_uid <span class="m">1</span> rack_id <span class="m">5</span> </span></span><span class="line"><span class="cl">Initiating cluster recovery... ok </span></span></code></pre> </div> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/cli-utilities/rladmin/cluster/recover/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/develop/data-types/json/resp3/.html
<section class="prose w-full py-12"> <h1> Guide for migrating from RESP2 to RESP3 replies </h1> <p class="text-lg -mt-5 mb-10"> JSON RESP2 to RESP3 replies reference for client developers </p> <p> In RESP3, the default value of the optional path argument was changed from <code> . </code> to <code> $ </code> . Due to this change, the replies of some commands have slightly changed. This page provides a brief comparison between RESP2 and RESP3 responses for JSON commands to help developers in migrating their clients from RESP2 to RESP3. </p> <h3 id="json-command-replies-comparison"> JSON command replies comparison </h3> <p> The types are described using a <a href="https://www.typescriptlang.org/docs/handbook/2/everyday-types.html"> β€œTypeScript-like” syntax </a> . <code> Array&lt;a&gt; </code> denotes an <a href="https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#arrays"> array </a> where the type of elements is known, but the number of elements is not. </p> <table> <thead> <tr> <th> Command </th> <th> RESP2 </th> <th> RESP3 </th> </tr> </thead> <tbody> <tr> <td> All JSON commands </td> <td> <strong> Default value of optional <code> path </code> argument </strong> : <code> . </code> </td> <td> <strong> Default value of optional <code> path </code> argument: </strong> <code> $ </code> </td> </tr> <tr> <td> JSON.ARRAPPEND <br/> JSON.ARRINDEX <br/> JSON.ARRINSERT <br/> JSON.ARRLEN <br/> JSON.ARRTRIM <br/> JSON.OBJLEN <br/> JSON.STRAPPEND <br/> JSON.STRLEN <br/> JSON.TOGGLE </td> <td> <em> <code> $ </code> -based path argument: </em> <br/> Reply: Array&lt;BulkString | null&gt; <br/> <br/> <em> <code> . </code> -based path argument : </em> <br/> Reply: BulkString </td> <td> <em> <code> $ </code> -based path argument: </em> <br/> Reply: Array&lt;number | null&gt; <br/> <br/> <em> <code> . </code> -based path argument : </em> <br/> Reply: number </td> </tr> <tr> <td> JSON.GET </td> <td> Reply: JSON encoded string <br/> Example: <br/> <code> &gt; JSON.SET k $ "[1,2,3]" </code> <br/> <code> &gt; JSON.GET k </code> <br/> <code> "[1,2,3]" </code> </td> <td> Reply: JSON encoded string with a top-level array <br/> Example: <br/> <code> &gt; JSON.SET k $ "[1,2,3]" </code> <br/> <code> &gt; JSON.GET k </code> <br/> <code> "[[1,2,3]]" </code> </td> </tr> <tr> <td> JSON.NUMINCRBY <br/> JSON.NUMMULTBY </td> <td> <em> <code> $ </code> -based path argument: </em> <br/> Reply: JSON-encoded BulkString | null <br/> <br/> <em> <code> . </code> -based path argument : </em> <br/> Reply: BulkString | null | error </td> <td> <em> <code> $ </code> -based path argument: </em> <br/> Reply: Array&lt;number | null&gt; | error <br/> <br/> <em> <code> . </code> -based path argument : </em> <br/> Reply: number | null | error </td> </tr> <tr> <td> JSON.OBJKEYS </td> <td> <em> <code> $ </code> -based path argument: </em> <br/> Reply: Array&lt;Array&lt;BulkString&gt;&gt; <br/> <br/> <em> <code> . </code> -based path argument : </em> <br/> Reply: Array&lt;BulkString&gt; </td> <td> <em> <code> $ </code> -based path argument: </em> <br/> Reply: Array&lt;Array&lt;BulkString&gt;&gt; <br/> <br/> <em> <code> . </code> -based path argument : </em> <br/> Reply: Array&lt;BulkString&gt; </td> </tr> <tr> <td> JSON.TYPE </td> <td> <em> <code> $ </code> -based path argument: </em> <br/> Reply: Array&lt;BulkString&gt; <br/> Example: <br/> <code> &gt; JSON.TYPE k $ </code> <br/> <code> 1) "array" </code> <br/> <br/> <em> <code> . </code> -based path argument : </em> <br/> Reply: BulkString </td> <td> <em> <code> $ </code> -based path argument: </em> <br/> Reply: Array&lt;Array&lt;BulkString&gt;&gt; <br/> Example: <br/> <code> &gt; JSON.TYPE k $ </code> <br/> <code> 1) 1) "array" </code> <br/> <br/> <em> <code> . </code> -based path argument : </em> <br/> Reply: Array&lt;BulkString&gt; </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/data-types/json/resp3/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/references/rest-api/requests/bdbs/actions/import/.html
<section class="prose w-full py-12 max-w-none"> <h1> Import database action requests </h1> <p class="text-lg -mt-5 mb-10"> Import database requests </p> <table> <thead> <tr> <th> Method </th> <th> Path </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="#post-bdbs-actions-import"> POST </a> </td> <td> <code> /v1/bdbs/{uid}/actions/import </code> </td> <td> Initiate manual dataset import </td> </tr> </tbody> </table> <h2 id="post-bdbs-actions-import"> Initiate manual dataset import </h2> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">POST /v1/bdbs/<span class="o">{</span>int: uid<span class="o">}</span>/actions/import </span></span></code></pre> </div> <p> Initiate a manual import process. </p> <h3 id="permissions"> Permissions </h3> <table> <thead> <tr> <th> Permission name </th> <th> Roles </th> </tr> </thead> <tbody> <tr> <td> <a href="/docs/latest/operate/rs/references/rest-api/permissions/#start_bdb_import"> start_bdb_import </a> </td> <td> admin <br/> cluster_member <br/> db_member </td> </tr> </tbody> </table> <h3 id="post-request"> Request </h3> <h4 id="example-http-request"> Example HTTP request </h4> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">POST /bdbs/1/actions/import </span></span></code></pre> </div> <h4 id="headers"> Headers </h4> <table> <thead> <tr> <th> Key </th> <th> Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> Host </td> <td> cnm.cluster.fqdn </td> <td> Domain name </td> </tr> <tr> <td> Accept </td> <td> application/json </td> <td> Accepted media type </td> </tr> <tr> <td> Content-Length </td> <td> 0 </td> <td> Length of the request body in octets </td> </tr> </tbody> </table> <h4 id="url-parameters"> URL parameters </h4> <table> <thead> <tr> <th> Field </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> uid </td> <td> integer </td> <td> The unique ID of the database </td> </tr> </tbody> </table> <h4 id="body"> Body </h4> <p> The request <em> may </em> contain a subset of the <a href="/docs/latest/operate/rs/references/rest-api/objects/bdb/"> BDB JSON object </a> , which includes the following import-related attributes: </p> <table> <thead> <tr> <th> Field </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> dataset_import_sources </td> <td> array of <a href="/docs/latest/operate/rs/references/rest-api/objects/bdb/dataset_import_sources/"> dataset_import_sources </a> objects </td> <td> Details for the import sources. Call <a href="/docs/latest/operate/rs/references/rest-api/requests/jsonschema/#get-jsonschema"> <code> GET /jsonschema </code> </a> on the bdb object and review the <code> dataset_import_sources </code> field to retrieve the object's structure. </td> </tr> <tr> <td> email_notification </td> <td> boolean </td> <td> Enable/disable an email notification on import failure/ completion. (optional) </td> </tr> </tbody> </table> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> Other attributes are not allowed and will cause the request to fail. </div> </div> <h5 id="example-json-body"> Example JSON Body </h5> <div class="highlight"> <pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"dataset_import_sources"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"type"</span><span class="p">:</span> <span class="s2">"url"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"url"</span><span class="p">:</span> <span class="s2">"http://..."</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"type"</span><span class="p">:</span> <span class="s2">"url"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"url"</span><span class="p">:</span> <span class="s2">"redis://..."</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="nt">"email_notification"</span><span class="p">:</span> <span class="kc">true</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <p> This request initiates an import process using <code> dataset_import_sources </code> values that were previously configured for the database. </p> <h3 id="post-response"> Response </h3> <p> Returns a status code. </p> <h3 id="post-status-codes"> Status codes </h3> <table> <thead> <tr> <th> Code </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1"> 200 OK </a> </td> <td> The request is accepted and is being processed. In order to monitor progress, the <code> import_status </code> , <code> import_progress </code> , and <code> import_failure_reason </code> attributes can be consulted. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5"> 404 Not Found </a> </td> <td> Attempting to perform an action on a nonexistent database. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.7"> 406Β NotΒ Acceptable </a> </td> <td> Not all the modules loaded to the database support 'backup_restore' capability. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.10"> 409 Conflict </a> </td> <td> Database is currently busy with another action. In this context, this is a temporary condition and the request should be reattempted later. </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/rest-api/requests/bdbs/actions/import/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/7.4/databases/configure/replica-ha/.html
<section class="prose w-full py-12 max-w-none"> <h1> Configure high availability for replica shards </h1> <p class="text-lg -mt-5 mb-10"> Configure high availability for replica shards so that the cluster automatically migrates the replica shards to an available node. </p> <p> When you enable <a href="/docs/latest/operate/rs/7.4/databases/durability-ha/replication/"> database replication </a> , Redis Enterprise Software creates a replica of each primary (master) shard. The replica shard will always be located on a different node than the primary shard to make your data highly available. If the primary shard fails or if the node hosting the primary shard fails, then the replica is promoted to primary. </p> <p> Without replica high availability ( <em> replica_ha </em> ) enabled, the promoted primary shard becomes a single point of failure as the only copy of the data. </p> <p> Enabling <em> replica_ha </em> configures the cluster to automatically replicate the promoted replica on an available node. This automatically returns the database to a state where there are two copies of the data: the former replica shard which has been promoted to primary and a new replica shard. </p> <p> An available node: </p> <ol> <li> Meets replica migration requirements, such as <a href="/docs/latest/operate/rs/7.4/clusters/configure/rack-zone-awareness/"> rack-awareness </a> . </li> <li> Has enough available RAM to store the replica shard. </li> <li> Does not also contain the master shard. </li> </ol> <p> In practice, replica migration creates a new replica shard and copies the data from the master shard to the new replica shard. </p> <p> For example: </p> <ol> <li> <p> Node:2 has a master shard and node:3 has the corresponding replica shard. </p> </li> <li> <p> Either: </p> <ul> <li> Node:2 fails and the replica shard on node:3 is promoted to master. </li> <li> Node:3 fails and the master shard is no longer replicated to the replica shard on the failed node. </li> </ul> </li> <li> <p> If replica HA is enabled, a new replica shard is created on an available node. </p> </li> <li> <p> The data from the master shard is replicated to the new replica shard. </p> </li> </ol> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> <ul> <li> Replica HA follows all prerequisites of replica migration, such as <a href="/docs/latest/operate/rs/7.4/clusters/configure/rack-zone-awareness/"> rack-awareness </a> . </li> <li> Replica HA migrates as many shards as possible based on available DRAM in the target node. When no DRAM is available, replica HA stops migrating replica shards to that node. </li> </ul> </div> </div> <h2 id="configure-high-availability-for-replica-shards"> Configure high availability for replica shards </h2> <p> If replica high availability is enabled for both the cluster and a database, the database's replica shards automatically migrate to another node when a master or replica shard fails. If replica HA is not enabled at the cluster level, replica HA will not migrate replica shards even if replica HA is enabled for a database. </p> <p> Replica high availability is enabled for the cluster by default. </p> <p> When you create a database using the Cluster Manager UI, replica high availability is enabled for the database by default if you enable replication. </p> <a href="/docs/latest/images/rs/screenshots/databases/config-replica-ha-enabled.png" sdata-lightbox="/images/rs/screenshots/databases/config-replica-ha-enabled.png"> <img alt="When you select the Replication checkbox in the High availability &amp; durability section of the database configuration screen, the Replica high availability checkbox is also selected by default." src="/docs/latest/images/rs/screenshots/databases/config-replica-ha-enabled.png"/> </a> <p> To use replication without replication high availability, clear the <strong> Replica high availability </strong> checkbox. </p> <p> You can also enable or turn off replica high availability for a database using <code> rladmin </code> or the REST API. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> For Active-Active databases, replica HA is enabled for the database by default to make sure that replica shards are available for Active-Active replication. </div> </div> <h3 id="configure-cluster-policy-for-replica-ha"> Configure cluster policy for replica HA </h3> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> The replica HA cluster policy is deprecated as of Redis Enterprise Software version 7.2.4. </div> </div> <p> To enable or turn off replica high availability by default for the entire cluster, use one of the following methods: </p> <ul> <li> <p> <a href="/docs/latest/operate/rs/7.4/references/cli-utilities/rladmin/tune/#tune-cluster"> rladmin tune cluster </a> : </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin tune cluster slave_ha <span class="o">{</span> enabled <span class="p">|</span> disabled <span class="o">}</span> </span></span></code></pre> </div> </li> <li> <p> <a href="/docs/latest/operate/rs/7.4/references/rest-api/requests/cluster/policy/#put-cluster-policy"> Update cluster policy </a> REST API request: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">PUT /v1/cluster/policy </span></span><span class="line"><span class="cl"><span class="o">{</span> <span class="s2">"slave_ha"</span>: &lt;boolean&gt; <span class="o">}</span> </span></span></code></pre> </div> </li> </ul> <h3 id="turn-off-replica-ha-for-a-database"> Turn off replica HA for a database </h3> <p> To turn off replica high availability for a specific database using <code> rladmin </code> , run: </p> <div class="highlight"> <pre class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">rladmin tune db db:&lt;ID&gt; slave_ha disabled </span></span></code></pre> </div> <p> You can use the database name in place of <code> db:&lt;ID&gt; </code> in the preceding command. </p> <h2 id="configuration-options"> Configuration options </h2> <p> You can see the current configuration options for replica HA with: </p> <div class="highlight"> <pre class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">rladmin info cluster </span></span></code></pre> </div> <h3 id="grace-period"> Grace period </h3> <p> By default, replica HA has a 10-minute grace period after node failure and before new replica shards are created. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> The default grace period is 30 minutes for containerized applications using <a href="/docs/latest/operate/kubernetes/"> Redis Enterprise Software for Kubernetes </a> . </div> </div> <p> To configure this grace period from rladmin, run: </p> <div class="highlight"> <pre class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">rladmin tune cluster slave_ha_grace_period &lt;time_in_seconds&gt; </span></span></code></pre> </div> <h3 id="shard-priority"> Shard priority </h3> <p> Replica shard migration is based on priority. When memory resources are limited, the most important replica shards are migrated first: </p> <ol> <li> <p> <code> slave_ha_priority </code> - Replica shards with higher integer values are migrated before shards with lower values. </p> <p> To assign priority to a database, run: </p> <div class="highlight"> <pre class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">rladmin tune db db:&lt;ID&gt; slave_ha_priority &lt;positive integer&gt; </span></span></code></pre> </div> <p> You can use the database name in place of <code> db:&lt;ID&gt; </code> in the preceding command. </p> </li> <li> <p> Active-Active databases - Active-Active database synchronization uses replica shards to synchronize between the replicas. </p> </li> <li> <p> Database size - It is easier and more efficient to move replica shards of smaller databases. </p> </li> <li> <p> Database UID - The replica shards of databases with a higher UID are moved first. </p> </li> </ol> <h3 id="cooldown-periods"> Cooldown periods </h3> <p> Both the cluster and the database have cooldown periods. </p> <p> After node failure, the cluster cooldown period ( <code> slave_ha_cooldown_period </code> ) prevents another replica migration due to another node failure for any database in the cluster until the cooldown period ends. The default is one hour. </p> <p> After a database is migrated with replica HA, it cannot go through another migration due to another node failure until the cooldown period for the database ( <code> slave_ha_bdb_cooldown_period </code> ) ends. The default is two hours. </p> <p> To configure cooldown periods, use <a href="/docs/latest/operate/rs/7.4/references/cli-utilities/rladmin/tune/#tune-cluster"> <code> rladmin tune cluster </code> </a> : </p> <ul> <li> <p> For the cluster: </p> <div class="highlight"> <pre class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">rladmin tune cluster slave_ha_cooldown_period &lt;time_in_seconds&gt; </span></span></code></pre> </div> </li> <li> <p> For all databases in the cluster: </p> <div class="highlight"> <pre class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">rladmin tune cluster slave_ha_bdb_cooldown_period &lt;time_in_seconds&gt; </span></span></code></pre> </div> </li> </ul> <h3 id="alerts"> Alerts </h3> <p> The following alerts are sent during replica HA activation: </p> <ul> <li> Shard migration begins after the grace period. </li> <li> Shard migration fails because there is no available node (sent hourly). </li> <li> Shard migration is delayed because of the cooldown period. </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/databases/configure/replica-ha/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/kubernetes/release-notes/7-2-4-releases/7-2-4-12-08-2024/.html
<section class="prose w-full py-12 max-w-none"> <h1> Redis Enterprise for Kubernetes 7.2.4-12 (August 2024) release notes </h1> <p class="text-lg -mt-5 mb-10"> This is a maintenance release to support Redis Enterprise Software version 7.2.4-109. </p> <h2 id="highlights"> Highlights </h2> <p> This is a maintenance release to support Redis Enterprise Software version 7.2.4-109. </p> <h2 id="new-in-this-release"> New in this release </h2> <h3 id="enhancements"> Enhancements </h3> <ul> <li> Added support for Redis Enterprise Software 7.2.4-109. </li> </ul> <h2 id="version-changes"> Version changes </h2> <p> For a list of fixes related to CVEs, see the <a href="/docs/latest/operate/rs/release-notes/rs-7-2-4-releases/rs-7-2-4-109/"> Redis Enterprise 7.2.4-109 release notes </a> . </p> <h3 id="breaking-changes"> Breaking changes </h3> <p> The following changes included in this release affect the upgrade process. Please read carefully before upgrading to 7.2.4-12. </p> <h4 id="upgrade-operating-system"> Upgrade operating system </h4> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Warning: </div> If your databases use modules, you need to update all nodes in the cluster to Redis Enterprise 7.2.4 or later before upgrading your operating system. See <a href="/docs/latest/operate/rs/installing-upgrading/upgrading/upgrade-os/"> Upgrade a cluster's operating system </a> in the Redis Enterprise Software documentation for more details. </div> </div> <h4 id="terminationgraceperiodseconds"> terminationGracePeriodSeconds </h4> <p> The configurable <code> terminationGracePeriodSeconds </code> REC field has been added to replace the hard-coded timeout of 15 minutes for a node to be stopped/drained (RED-111471). </p> <h4 id="validatingwebhookconfiguration"> ValidatingWebhookConfiguration </h4> <p> Versions 6.4.2-4 and later include a new <code> ValidatingWebhookConfiguration </code> resource to replace the <code> redb-admission </code> webhook resource. To use releases 6.4.2-4 or later, delete the old webhook resource and apply the new file. See <a href="/docs/latest/operate/kubernetes/upgrade/upgrade-redis-cluster/#reapply-webhook"> upgrade Redis cluster </a> for instructions. </p> <h4 id="openshift-scc"> OpenShift SCC </h4> <p> Versions 6.4.2-6 and later include a new SCC ( <code> redis-enterprise-scc-v2 </code> ) that you need to bind to your service account before upgrading. OpenShift clusters running version 6.2.12 or earlier upgrading to version 6.2.18 or later might get stuck if you skip this step. See <a href="/docs/latest/operate/kubernetes/upgrade/upgrade-redis-cluster/#before-upgrading"> upgrade a Redis Enterprise cluster (REC) </a> for instructions. </p> <h3 id="upcoming-changes"> Upcoming changes </h3> <ul> <li> A future release of Redis Enterprise will remove support for RHEL7. We recommend migrating to RHEL8. </li> </ul> <h3 id="supported-distributions"> Supported distributions </h3> <p> The following table shows supported distributions at the time of this release. You can also find this list in <a href="/docs/latest/operate/kubernetes/reference/supported_k8s_distributions/"> Supported Kubernetes distributions </a> . </p> <p> <span title="Check mark icon"> βœ… </span> Supported – This distribution is supported for this version of Redis Enterprise Software for Kubernetes. </p> <p> <span title="Warning icon"> ⚠️ </span> Deprecated – This distribution is still supported for this version of Redis Enterprise Software for Kubernetes, but support will be removed in a future release. </p> <p> <span title="X icon"> ❌ </span> End of life – Support for this distribution ended. </p> <p> Any distribution not listed below is not supported for production workloads. </p> <table> <thead> <tr> <th> <strong> Kubernetes version </strong> </th> <th> <strong> 1.23 </strong> </th> <th> <strong> 1.24 </strong> </th> <th> <strong> 1.25 </strong> </th> <th> <strong> 1.26 </strong> </th> <th> <strong> 1.27 </strong> </th> <th> <strong> 1.28 </strong> </th> </tr> </thead> <tbody> <tr> <td> Community Kubernetes </td> <td> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> </tr> <tr> <td> Amazon EKS </td> <td> <span title="Deprecation warning"> ⚠️ </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> </td> </tr> <tr> <td> Azure AKS </td> <td> </td> <td> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> </td> </tr> <tr> <td> Google GKE </td> <td> <span title="X icon"> ❌ </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> </td> </tr> <tr> <td> Rancher 2.6 </td> <td> <span title="X icon"> ❌ </span> </td> <td> <span title="X icon"> ❌ </span> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> Rancher RKE2 </td> <td> <span title="Deprecation warning"> ⚠️ </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> </td> <td> </td> </tr> <tr> <td> VMware TKG 2.1 </td> <td> <span title="Deprecation warning"> ⚠️ </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> VMware TKG 2.2 </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> VMware TKG 2.3 </td> <td> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> </td> <td> </td> </tr> <tr> <td> <strong> OpenShift version </strong> </td> <td> <strong> 4.10 </strong> </td> <td> <strong> 4.11 </strong> </td> <td> <strong> 4.12 </strong> </td> <td> <strong> 4.13 </strong> </td> <td> <strong> 4.14 </strong> </td> <td> </td> </tr> <tr> <td> </td> <td> <span title="X icon"> ❌ </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> </td> </tr> <tr> <td> <strong> VMware TKGI version </strong> </td> <td> <strong> 1.14 </strong> </td> <td> <strong> 1.15 </strong> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> <span title="X icon"> ❌ </span> </td> <td> <span title="Supported"> βœ… </span> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> </tbody> </table> <h2 id="downloads"> Downloads </h2> <ul> <li> <strong> Redis Enterprise </strong> : <code> redislabs/redis:7.2.4-109 </code> </li> <li> <strong> Operator </strong> : <code> redislabs/operator:7.2.4-12 </code> </li> <li> <strong> Services Rigger </strong> : <code> redislabs/k8s-controller:7.2.4-12. </code> </li> </ul> <h4 id="openshift-images"> OpenShift images </h4> <ul> <li> <strong> Redis Enterprise </strong> : <code> registry.connect.redhat.com/redislabs/redis-enterprise:7.2.4-109.rhel8-openshift </code> (or <code> redislabs/redis-enterprise:7.2.4-109.rhel7-openshift </code> if upgrading from RHEL 7) </li> <li> <strong> Operator </strong> : <code> registry.connect.redhat.com/redislabs/redis-enterprise-operator:7.2.4-12 </code> </li> <li> <strong> Services Rigger </strong> : <code> registry.connect.redhat.com/redislabs/services-manager:7.2.4-12 </code> </li> </ul> <h4 id="olm-bundle"> OLM bundle </h4> <p> <strong> Redis Enterprise operator bundle </strong> : <code> v7.2.4-12.11 </code> </p> <h2 id="known-limitations"> Known limitations </h2> <p> The limitations below are specific to the Redis Enterprise for Kubernetes product. To view limitations for the supported Redis Enterprise Software version, see the <a href="/docs/latest/operate/rs/release-notes/rs-7-2-4-releases/#known-limitations"> 7.2.4 release notes </a> . </p> <h3 id="existing-limitations"> Existing limitations </h3> <ul> <li> <p> <strong> When modifying the database suffix for an Active-Active database, while the service-rigger is in a terminating state, the services-rigger will delete and create the ingress or route resources in a loop (RED-107687) </strong> Wait until the services- rigger pod has finished to terminate it. </p> </li> <li> <p> <strong> REAADB changes might fail with "gateway timeout" errors, mostly on OpenShift (RED-103048) </strong> Retry the operation. </p> </li> <li> <p> <strong> Creating two databases with the same name directly on Redis Enterprise software will cause the service to be deleted and the database will not be available (RED-99997) </strong> Avoid duplicating database names. Database creation via K8s has validation in place to prevent this. </p> </li> <li> <p> <strong> Installing the operator bundle produces warning: <code> Warning: would violate PodSecurity "restricted: v1.24" </code> (RED-97381) </strong> Ignore the warning. This issue is documented as benign on official Red Hat documentation. </p> </li> <li> <p> <strong> RERC resources must have a unique name (RED-96302) </strong> The string "rec-name"/"rec-namespace" must be different from all other participating clusters in the Active-Active database. </p> </li> <li> <p> <strong> Admission is not blocking REAADB with <code> shardCount </code> which exceeds license quota (RED-96301) </strong> Fix the problems with the REAADB and reapply. </p> </li> <li> <p> <strong> Active-Active controller only supports global database options. Configuration specific to location is not supported (RED-86490) </strong> </p> </li> <li> <p> <strong> Active-Active setup removal might keep services or routes undeleted (RED-77752) </strong> Delete services or routes manually if you encounter this problem. </p> </li> <li> <p> <strong> <code> autoUpgrade </code> set to <code> true </code> can cause unexpected bdb upgrades when <code> redisUpgradePolicy </code> is set to <code> true </code> (RED-72351) </strong> Contact support if your deployment is impacted. </p> </li> <li> <p> <strong> Following the previous quick start guide version causes issues with creating an REDB due to unrecognized memory field name (RED-69515) </strong> The workaround is to use the newer (current) revision of Deploy Redis Enterprise Software for Kubernetes. </p> </li> <li> <p> <strong> PVC size issues when using decimal value in spec (RED-62132) </strong> Make sure you use integer values for the PVC size. </p> </li> <li> <p> <strong> REC might report error states on initial startup (RED-61707) </strong> There is no workaround at this time except to ignore the errors. </p> </li> <li> <p> <strong> Hashicorp Vault integration - no support for Gesher (RED-55080) </strong> There is no workaround for this issue. Gesher support has been deprecated. </p> </li> <li> <p> <strong> REC clusters fail to start on Kubernetes clusters with unsynchronized clocks (RED-47254) </strong> When REC clusters are deployed on Kubernetes clusters without synchronized clocks, the REC cluster does not start correctly. The fix is to use NTP to synchronize the underlying K8s nodes. </p> </li> <li> <p> <strong> Deleting an OpenShift project with an REC deployed may hang (RED-47192) </strong> When an REC cluster is deployed in a project (namespace) and has REDB resources, the REDB resources must be deleted first before the REC can be deleted. Therefore, until the REDB resources are deleted, the project deletion will hang. The fix is to delete the REDB resources first and the REC second. Then, you can delete the project. </p> </li> <li> <p> <strong> Clusters must be named 'rec' in OLM-based deployments (RED-39825) </strong> In OLM-deployed operators, the deployment of the cluster will fail if the name is not "rec". When the operator is deployed via the OLM, the security context constraints (scc) are bound to a specific service account name (namely, "rec"). The workaround is to name the cluster "rec". </p> </li> <li> <p> <strong> Readiness probe incorrect on failures (RED-39300) </strong> STS Readiness probe does not mark a node as "not ready" when running <code> rladmin status </code> on node failure. </p> </li> <li> <p> <strong> Internal DNS and Kubernetes DNS may have conflicts (RED-37462) </strong> DNS conflicts are possible between the cluster <code> mdns_server </code> and the K8s DNS. This only impacts DNS resolution from within cluster nodes for Kubernetes DNS names. </p> </li> <li> <p> <strong> K8s-based 5.4.10 clusters seem to negatively affect existing 5.4.6 clusters (RED-37233) </strong> Upgrade clusters to the latest version. </p> </li> <li> <p> <strong> Node CPU usage is reported instead of pod CPU usage (RED-36884) </strong> In Kubernetes, the reported node CPU usage is the usage of the Kubernetes worker node hosting the REC pod. </p> </li> <li> <p> <strong> An unreachable cluster has status running (RED-32805) </strong> When a cluster is in an unreachable state, the state remains <code> running </code> instead of triggering an error. </p> </li> <li> <p> <strong> Long cluster names cause routes to be rejected (RED-25871) </strong> A cluster name longer than 20 characters will result in a rejected route configuration because the host part of the domain name exceeds 63 characters. The workaround is to limit the cluster name to 20 characters or fewer. </p> </li> <li> <p> <strong> Cluster CR (REC) errors are not reported after invalid updates (RED-25542) </strong> A cluster CR specification error is not reported if two or more invalid CR resources are updated in sequence. </p> </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/kubernetes/release-notes/7-2-4-releases/7-2-4-12-08-2024/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/ts.decrby.html
<section class="prose w-full py-12"> <h1 class="command-name"> TS.DECRBY </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">TS.DECRBY key subtrahend [TIMESTAMP timestamp] [RETENTION retentionPeriod] [ENCODING &lt;COMPRESSED|UNCOMPRESSED&gt;] [CHUNK_SIZE size] [DUPLICATE_POLICY policy] [IGNORE ignoreMaxTimediff ignoreMaxValDiff] [LABELS [label value ...]] </pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available in: </dt> <dd class="m-0"> <a href="/docs/stack"> Redis Stack </a> / <a href="/docs/data-types/timeseries"> TimeSeries 1.0.0 </a> </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(M) when M is the amount of compaction rules or O(1) with no compaction </dd> </dl> <p> Decrease the value of the sample with the maximum existing timestamp, or create a new sample with a value equal to the value of the sample with the maximum existing timestamp with a given decrement </p> <p> <a href="#examples"> Examples </a> </p> <h2 id="required-arguments"> Required arguments </h2> <details open=""> <summary> <code> key </code> </summary> <p> is key name for the time series. </p> </details> <details open=""> <summary> <code> subtrahend </code> </summary> <p> is numeric value of the subtrahend (double). </p> </details> <p> <note> <b> Notes </b> </note> </p> <ul> <li> When specified key does not exist, a new time series is created. </li> <li> You can use this command as a counter or gauge that automatically gets history as a time series. </li> <li> If a policy for handling duplicate samples ( <code> IGNORE </code> ) is defined for this time series - <code> TS.DECRBY </code> operations are affected as well (sample additions/modifications can be filtered). </li> <li> Explicitly adding samples to a compacted time series (using <a href="/docs/latest/commands/ts.add/"> <code> TS.ADD </code> </a> , <a href="/docs/latest/commands/ts.madd/"> <code> TS.MADD </code> </a> , <a href="/docs/latest/commands/ts.incrby/"> <code> TS.INCRBY </code> </a> , or <code> TS.DECRBY </code> ) may result in inconsistencies between the raw and the compacted data. The compaction process may override such samples. </li> </ul> <h2 id="optional-arguments"> Optional arguments </h2> <details open=""> <summary> <code> TIMESTAMP timestamp </code> </summary> <p> is Unix time (integer, in milliseconds) specifying the sample timestamp or <code> * </code> to set the sample timestamp to the Unix time of the server's clock. </p> <p> Unix time is the number of milliseconds that have elapsed since 00:00:00 UTC on 1 January 1970, the Unix epoch, without adjustments made due to leap seconds. </p> <p> <code> timestamp </code> must be equal to or higher than the maximum existing timestamp. When equal, the value of the sample with the maximum existing timestamp is decreased. If it is higher, a new sample with a timestamp set to <code> timestamp </code> is created, and its value is set to the value of the sample with the maximum existing timestamp minus <code> subtrahend </code> . </p> <p> If the time series is empty, the value is set to <code> subtrahend </code> . </p> <p> When not specified, the timestamp is set to the Unix time of the server's clock. </p> </details> <details open=""> <summary> <code> RETENTION retentionPeriod </code> <p> is maximum retention period, compared to the maximum existing timestamp, in milliseconds. </p> <p> Use it only if you are creating a new time series. It is ignored if you are adding samples to an existing time series. See <code> RETENTION </code> in <a href="/docs/latest/commands/ts.create/"> <code> TS.CREATE </code> </a> . </p> </summary> </details> <details open=""> <summary> <code> ENCODING enc </code> </summary> <p> specifies the series sample encoding format. </p> <p> Use it only if you are creating a new time series. It is ignored if you are adding samples to an existing time series. See <code> ENCODING </code> in <a href="/docs/latest/commands/ts.create/"> <code> TS.CREATE </code> </a> . </p> </details> <details open=""> <summary> <code> CHUNK_SIZE size </code> </summary> <p> is memory size, in bytes, allocated for each data chunk. </p> <p> Use it only if you are creating a new time series. It is ignored if you are adding samples to an existing time series. See <code> CHUNK_SIZE </code> in <a href="/docs/latest/commands/ts.create/"> <code> TS.CREATE </code> </a> . </p> </details> <details open=""> <summary> <code> DUPLICATE_POLICY policy </code> </summary> <p> is policy for handling insertion ( <a href="/docs/latest/commands/ts.add/"> <code> TS.ADD </code> </a> and <a href="/docs/latest/commands/ts.madd/"> <code> TS.MADD </code> </a> ) of multiple samples with identical timestamps. </p> <p> Use it only if you are creating a new time series. It is ignored if you are adding samples to an existing time series. See <code> DUPLICATE_POLICY </code> in <a href="/docs/latest/commands/ts.create/"> <code> TS.CREATE </code> </a> . </p> </details> <details open=""> <summary> <code> IGNORE ignoreMaxTimediff ignoreMaxValDiff </code> </summary> <p> is the policy for handling duplicate samples. A new sample is considered a duplicate and is ignored if the following conditions are met: </p> <ul> <li> The time series is not a compaction; </li> <li> The time series' <code> DUPLICATE_POLICY </code> IS <code> LAST </code> ; </li> <li> The sample is added in-order ( <code> timestamp β‰₯ max_timestamp </code> ); </li> <li> The difference of the current timestamp from the previous timestamp ( <code> timestamp - max_timestamp </code> ) is less than or equal to <code> IGNORE_MAX_TIME_DIFF </code> ; </li> <li> The absolute value difference of the current value from the value at the previous maximum timestamp ( <code> abs(value - value_at_max_timestamp </code> ) is less than or equal to <code> IGNORE_MAX_VAL_DIFF </code> . </li> </ul> <p> where <code> max_timestamp </code> is the timestamp of the sample with the largest timestamp in the time series, and <code> value_at_max_timestamp </code> is the value at <code> max_timestamp </code> . </p> <p> When not specified: set to the global <a href="/docs/latest/develop/data-types/timeseries/configuration#ignore_max_time_diff-and-ignore_max_val_diff"> IGNORE_MAX_TIME_DIFF </a> and <a href="/docs/latest/develop/data-types/timeseries/configuration#ignore_max_time_diff-and-ignore_max_val_diff"> IGNORE_MAX_VAL_DIFF </a> , which are, by default, both set to 0. </p> <p> These parameters are used when creating a new time series to set the per-key parameters, and are ignored when called with an existing time series (the existing per-key configuration parameters are used). </p> </details> <details open=""> <summary> <code> LABELS [{label value}...] </code> </summary> <p> is set of label-value pairs that represent metadata labels of the key and serve as a secondary index. </p> <p> Use it only if you are creating a new time series. It is ignored if you are adding samples to an existing time series. See <code> LABELS </code> in <a href="/docs/latest/commands/ts.create/"> <code> TS.CREATE </code> </a> . </p> </details> <p> <note> <b> Notes </b> </note> </p> <ul> <li> You can use this command to create a new time series and add a sample to it in a single command. <code> RETENTION </code> , <code> ENCODING </code> , <code> CHUNK_SIZE </code> , <code> DUPLICATE_POLICY </code> , <code> IGNORE </code> , and <code> LABELS </code> are used only when creating a new time series, and ignored when adding or modifying samples in an existing time series. </li> <li> Setting <code> RETENTION </code> and <code> LABELS </code> introduces additional time complexity. </li> </ul> <h2 id="return-value"> Return value </h2> <p> Returns one of these replies: </p> <ul> <li> <a href="/docs/latest/develop/reference/protocol-spec/#integers"> Integer reply </a> - the timestamp of the upserted sample. If the sample is ignored (See <code> IGNORE </code> in <a href="/docs/latest/commands/ts.create/"> <code> TS.CREATE </code> </a> ), the reply will be the largest timestamp in the time series. </li> <li> [] on error (invalid arguments, wrong key type, etc.), or when <code> timestamp </code> is not equal to or higher than the maximum existing timestamp </li> </ul> <h2 id="see-also"> See also </h2> <p> <a href="/docs/latest/commands/ts.incrby/"> <code> TS.INCRBY </code> </a> | <a href="/docs/latest/commands/ts.create/"> <code> TS.CREATE </code> </a> </p> <h2 id="related-topics"> Related topics </h2> <p> <a href="/docs/latest/develop/data-types/timeseries/"> RedisTimeSeries </a> </p> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/ts.decrby/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/kubernetes/reference/redis_enterprise_remote_cluster_api/.html
<section class="prose w-full py-12 max-w-none"> <h1> RedisEnterpriseRemoteCluster API Reference </h1> <p> apiVersion: </p> <ul> <li> <a href="#appredislabscomv1alpha1"> app.redislabs.com/v1alpha1 </a> </li> </ul> <h1 id="appredislabscomv1alpha1"> app.redislabs.com/v1alpha1 </h1> <p> RedisEntepriseRemoteCluster represents a remote participating cluster. </p> <table> <thead> <tr> <th> Name </th> <th> Type </th> <th> Description </th> <th> Required </th> </tr> </thead> <tbody> <tr> <td> apiVersion </td> <td> string </td> <td> app.redislabs.com/v1alpha1 </td> <td> true </td> </tr> <tr> <td> kind </td> <td> string </td> <td> RedisEnterpriseRemoteCluster </td> <td> true </td> </tr> <tr> <td> <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#objectmeta-v1-meta"> metadata </a> </td> <td> object </td> <td> Refer to the Kubernetes API documentation for the fields of the `metadata` field. </td> <td> true </td> </tr> <tr> <td> <a href="#spec"> spec </a> </td> <td> object </td> <td> <br/> </td> <td> false </td> </tr> <tr> <td> <a href="#status"> status </a> </td> <td> object </td> <td> <br/> </td> <td> false </td> </tr> </tbody> </table> <h3 id="spec"> spec </h3> <p> <sup> <sup> <a href="#"> ↩ Parent </a> </sup> </sup> </p> <table> <thead> <tr> <th> Name </th> <th> Type </th> <th> Description </th> <th> Required </th> </tr> </thead> <tbody> <tr> <td> apiFqdnUrl </td> <td> string </td> <td> The URL of the cluster, will be used for the active-active database URL. <br/> </td> <td> true </td> </tr> <tr> <td> recName </td> <td> string </td> <td> The name of the REC that the RERC is pointing at <br/> </td> <td> true </td> </tr> <tr> <td> recNamespace </td> <td> string </td> <td> The namespace of the REC that the RERC is pointing at <br/> </td> <td> true </td> </tr> <tr> <td> dbFqdnSuffix </td> <td> string </td> <td> The database URL suffix, will be used for the active-active database replication endpoint and replication endpoint SNI. <br/> </td> <td> false </td> </tr> <tr> <td> secretName </td> <td> string </td> <td> The name of the secret containing cluster credentials. Must be of the following format: "redis-enterprise- <rerc name=""> " <br/> </rerc> </td> <td> false </td> </tr> </tbody> </table> <h3 id="status"> status </h3> <p> <sup> <sup> <a href="#"> ↩ Parent </a> </sup> </sup> </p> <table> <thead> <tr> <th> Name </th> <th> Type </th> <th> Description </th> <th> Required </th> </tr> </thead> <tbody> <tr> <td> local </td> <td> boolean </td> <td> Indicates whether this object represents a local or a remote cluster. <br/> </td> <td> false </td> </tr> <tr> <td> observedGeneration </td> <td> integer </td> <td> The most recent generation observed for this RERC. It corresponds to the RERC's generation, which is updated by the API Server. <br/> </td> <td> false </td> </tr> <tr> <td> specStatus </td> <td> string </td> <td> Whether the desired specification is valid. <br/> </td> <td> false </td> </tr> <tr> <td> status </td> <td> string </td> <td> The status of the remote cluster. <br/> </td> <td> false </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/kubernetes/reference/redis_enterprise_remote_cluster_api/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/installing-upgrading/upgrading/upgrade-os/.html
<section class="prose w-full py-12 max-w-none"> <h1> Upgrade a cluster's operating system </h1> <p class="text-lg -mt-5 mb-10"> Upgrade a Redis Enterprise Software cluster's operating system to a later major version. </p> <p> To upgrade the operating system (OS) on a Redis Enterprise Software cluster to a later major version, perform a rolling upgrade. Because you upgrade one node at a time, you can upgrade your cluster's OS without downtime. </p> <h2 id="prerequisites"> Prerequisites </h2> <p> Before you upgrade a cluster's operating system: </p> <ol> <li> <p> <a href="/docs/latest/operate/rs/installing-upgrading/upgrading/upgrade-cluster/"> Upgrade all nodes in the cluster </a> to a Redis Enterprise Software version that supports the OS's current version and upgrade version. </p> <p> To learn which versions of Redis Enterprise Software support specific OS versions, see <a href="/docs/latest/operate/rs/references/supported-platforms/#supported-platforms"> Supported platforms </a> . </p> </li> <li> <p> If the cluster contains databases that use modules: </p> <ol> <li> <p> Update all nodes in the cluster to <a href="/docs/latest/operate/rs/release-notes/rs-7-2-4-releases/"> Redis Enterprise Software version 7.2.4-52 </a> or later before you upgrade the OS. </p> </li> <li> <p> Check the status of modules using <a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/"> <code> rladmin </code> </a> : </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin status modules </span></span></code></pre> </div> <p> The output lists the module versions installed on the cluster and the module versions used by existing databases: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">CLUSTER MODULES: </span></span><span class="line"><span class="cl">MODULE VERSION </span></span><span class="line"><span class="cl">RedisBloom 2.6.3 </span></span><span class="line"><span class="cl">RediSearch <span class="m">2</span> 2.8.4 </span></span><span class="line"><span class="cl">RedisGears 2.0.12 </span></span><span class="line"><span class="cl">RedisGraph 2.10.12 </span></span><span class="line"><span class="cl">RedisJSON 2.6.6 </span></span><span class="line"><span class="cl">RedisTimeSeries 1.10.6 </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl">DATABASE MODULES: </span></span><span class="line"><span class="cl">DB:ID NAME MODULE VERSION ARGS STATUS </span></span><span class="line"><span class="cl">db:1 db1 RediSearch <span class="m">2</span> 2.6.9 PARTITIONS AUTO OK, OLD MODULE VERSION </span></span><span class="line"><span class="cl">db:1 db1 RedisJSON 2.4.7 OK, OLD MODULE VERSION </span></span></code></pre> </div> </li> <li> <p> If any databases use custom modules, manually uploaded modules, or modules marked with <code> OLD MODULE VERSION </code> , upload module packages for the OS upgrade version to a cluster node. See <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/install/add-module-to-cluster/"> Install a module on a cluster </a> for instructions. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> <p> The uploaded module packages have the following requirements: </p> <ul> <li> <p> The module is compiled for the OS upgrade version. </p> </li> <li> <p> The module version matches the version currently used by databases. </p> </li> </ul> </div> </div> </li> </ol> </li> <li> <p> If the cluster uses custom directories, make sure the OS upgrade version also supports custom directories, and specify the same custom directories during installation for all nodes. See <a href="/docs/latest/operate/rs/installing-upgrading/install/customize-install-directories/"> Customize installation directories </a> for details. </p> </li> </ol> <h2 id="perform-os-rolling-upgrade"> Perform OS rolling upgrade </h2> <p> To upgrade the cluster's operating system, use one of the following rolling upgrade methods: </p> <ul> <li> <p> <a href="#extra-node-upgrade"> Extra node method </a> - recommended if you have additional resources available </p> </li> <li> <p> <a href="#replace-node-upgrade"> Replace node method </a> - recommended if you cannot temporarily allocate additional resources </p> </li> </ul> <h3 id="extra-node-upgrade"> Extra node upgrade method </h3> <ol> <li> <p> Create a node with the OS upgrade version. </p> </li> <li> <p> <a href="/docs/latest/operate/rs/installing-upgrading/install/install-on-linux/"> Install the cluster's current Redis Enterprise Software version </a> on the new node using the installation package for the OS upgrade version. </p> </li> <li> <p> <a href="/docs/latest/operate/rs/clusters/add-node/"> Add the new node </a> to the cluster. </p> </li> <li> <p> <a href="/docs/latest/operate/rs/clusters/remove-node/#remove-a-node"> Remove one node </a> running the earlier OS version from the cluster. </p> </li> <li> <p> Repeat the previous steps until all nodes with the earlier OS version are removed. </p> </li> </ol> <h3 id="replace-node-upgrade"> Replace node upgrade method </h3> <ol> <li> <p> <a href="/docs/latest/operate/rs/clusters/remove-node/#remove-a-node"> Remove a node </a> with the earlier OS version from the cluster. </p> </li> <li> <p> Uninstall Redis Enterprise Software from the removed node: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">sudo ./rl_uninstall.sh </span></span></code></pre> </div> </li> <li> <p> Either upgrade the existing node to the OS upgrade version, or create a new node with the OS upgrade version. </p> </li> <li> <p> <a href="/docs/latest/operate/rs/installing-upgrading/install/install-on-linux/"> Install the cluster's current Redis Enterprise Software version </a> on the upgraded node using the installation package for the OS upgrade version. </p> </li> <li> <p> <a href="/docs/latest/operate/rs/clusters/add-node/"> Add the new node </a> to the cluster. </p> <p> If you want to reuse the removed node's ID when you add the node to the cluster, run <a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/cluster/join/"> <code> rladmin cluster join </code> </a> with the <code> replace_node </code> flag: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin cluster join nodes &lt;cluster_member_ip_address&gt; username &lt;username&gt; password &lt;password&gt; replace_node &lt;node_id&gt; </span></span></code></pre> </div> </li> <li> <p> Verify node health: </p> <ol> <li> <p> Run <code> rlcheck </code> on all nodes: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rlcheck </span></span></code></pre> </div> <p> The output lists the result of each verification test: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl"><span class="c1">##### Welcome to Redis Enterprise Cluster settings verification utility ####</span> </span></span><span class="line"><span class="cl">Running test: verify_bootstrap_status </span></span><span class="line"><span class="cl"> PASS </span></span><span class="line"><span class="cl">... </span></span><span class="line"><span class="cl">Running test: verify_encrypted_gossip </span></span><span class="line"><span class="cl"> PASS </span></span><span class="line"><span class="cl">Summary: </span></span><span class="line"><span class="cl">------- </span></span><span class="line"><span class="cl">ALL TESTS PASSED. </span></span></code></pre> </div> <p> For healthy nodes, the expected output is <code> ALL TESTS PASSED </code> . </p> </li> <li> <p> Run <a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/status/"> <code> rladmin status </code> </a> on the new node: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin status extra all </span></span></code></pre> </div> <p> The expected output is the <code> OK </code> status for the cluster, nodes, endpoints, and shards: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">CLUSTER: </span></span><span class="line"><span class="cl">OK. Cluster master: <span class="m">2</span> <span class="o">(</span>&lt;IP.address&gt;<span class="o">)</span> </span></span><span class="line"><span class="cl">Cluster health: OK, <span class="o">[</span>0, 0.0, 0.0<span class="o">]</span> </span></span><span class="line"><span class="cl">failures/minute - avg1 0.00, avg15 0.00, avg60 0.00. </span></span><span class="line"><span class="cl">... </span></span></code></pre> </div> </li> </ol> </li> <li> <p> Repeat the previous steps until all nodes with the earlier OS version are replaced. </p> </li> </ol> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/installing-upgrading/upgrading/upgrade-os/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/develop/data-types/json/use_cases/.html
<section class="prose w-full py-12"> <h1> Use cases </h1> <p class="text-lg -mt-5 mb-10"> JSON use cases </p> <p> You can of course use Redis native data structures to store JSON objects, and that's a common practice. For example, you can serialize JSON and save it in a Redis String. </p> <p> However, Redis JSON provides several benefits over this approach. </p> <p> <strong> Access and retrieval of subvalues </strong> </p> <p> With JSON, you can get nested values without having to transmit the entire object over the network. Being able to access sub-objects can lead to greater efficiencies when you're storing large JSON objects in Redis. </p> <p> <strong> Atomic partial updates </strong> </p> <p> JSON allows you to atomically run operations like incrementing a value, adding, or removing elements from an array, append strings, and so on. To do the same with a serialized object, you have to retrieve and then reserialize the entire object, which can be expensive and also lack atomicity. </p> <p> <strong> Indexing and querying </strong> </p> <p> When you store JSON objects as Redis strings, there's no good way to query those objects. On the other hand, storing these objects as JSON using Redis Stack lets you index and query them. This capability is provided by the Redis Query Engine. </p> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/data-types/json/use_cases/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/keys/.html
<section class="prose w-full py-12"> <h1 class="command-name"> KEYS </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">KEYS pattern</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 1.0.0 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(N) with N being the number of keys in the database, under the assumption that the key names in the database and the given pattern have limited length. </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @keyspace </code> <span class="mr-1 last:hidden"> , </span> <code> @read </code> <span class="mr-1 last:hidden"> , </span> <code> @slow </code> <span class="mr-1 last:hidden"> , </span> <code> @dangerous </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> Returns all keys matching <code> pattern </code> . </p> <p> While the time complexity for this operation is O(N), the constant times are fairly low. For example, Redis running on an entry level laptop can scan a 1 million key database in 40 milliseconds. </p> <p> <strong> Warning </strong> : consider <code> KEYS </code> as a command that should only be used in production environments with extreme care. It may ruin performance when it is executed against large databases. This command is intended for debugging and special operations, such as changing your keyspace layout. Don't use <code> KEYS </code> in your regular application code. If you're looking for a way to find keys in a subset of your keyspace, consider using <a href="/docs/latest/commands/scan/"> <code> SCAN </code> </a> or <a href="/docs/latest/develop/data-types/sets/"> sets </a> . </p> <p> Supported glob-style patterns: </p> <ul> <li> <code> h?llo </code> matches <code> hello </code> , <code> hallo </code> and <code> hxllo </code> </li> <li> <code> h*llo </code> matches <code> hllo </code> and <code> heeeello </code> </li> <li> <code> h[ae]llo </code> matches <code> hello </code> and <code> hallo, </code> but not <code> hillo </code> </li> <li> <code> h[^e]llo </code> matches <code> hallo </code> , <code> hbllo </code> , ... but not <code> hello </code> </li> <li> <code> h[a-b]llo </code> matches <code> hallo </code> and <code> hbllo </code> </li> </ul> <p> Use <code> \ </code> to escape special characters if you want to match them verbatim. </p> <p> When using <a href="/docs/latest/operate/oss_and_stack/management/scaling/"> Redis Cluster </a> , the search is optimized for patterns that imply a single slot. If a pattern can only match keys of one slot, Redis only iterates over keys in that slot, rather than the whole database, when searching for keys matching the pattern. For example, with the pattern <code> {a}h*llo </code> , Redis would only try to match it with the keys in slot 15495, which hash tag <code> {a} </code> implies. To use pattern with hash tag, see <a href="/docs/latest/operate/oss_and_stack/reference/cluster-spec#hash-tags"> Hash tags </a> in the Cluster specification for more information. </p> <h2 id="examples"> Examples </h2> <div class="bg-slate-900 border-b border-slate-700 rounded-t-xl px-4 py-3 w-full flex"> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10Z"> </path> </svg> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M10 2.5L18.6603 17.5L1.33975 17.5L10 2.5Z"> </path> </svg> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M10 2.5L12.0776 7.9322L17.886 8.22949L13.3617 11.8841L14.8738 17.5L10 14.3264L5.1262 17.5L6.63834 11.8841L2.11403 8.22949L7.92238 7.9322L10 2.5Z"> </path> </svg> </div> <form class="redis-cli overflow-y-auto max-h-80"> <pre tabindex="0">redis&gt; MSET firstname Jack lastname Stuntman age 35 "OK" redis&gt; KEYS *name* 1) "lastname" 2) "firstname" redis&gt; KEYS a?? 1) "age" redis&gt; KEYS * 1) "lastname" 2) "age" 3) "firstname" </pre> <div class="prompt" style=""> <span> redis&gt; </span> <input autocomplete="off" name="prompt" spellcheck="false" type="text"/> </div> </form> <h2 id="resp2resp3-reply"> RESP2/RESP3 Reply </h2> <a href="../../develop/reference/protocol-spec#arrays"> Array reply </a> : a list of keys matching <em> pattern </em> . <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/keys/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/references/rest-api/requests/bdbs/actions/recover/.html
<section class="prose w-full py-12 max-w-none"> <h1> Recover database requests </h1> <p class="text-lg -mt-5 mb-10"> REST API requests for database recovery </p> <table> <thead> <tr> <th> Method </th> <th> Path </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="#get-bdbs-actions-recover"> GET </a> </td> <td> <code> /v1/bdbs/{uid}/actions/recover </code> </td> <td> Get database recovery plan </td> </tr> <tr> <td> <a href="#post-bdbs-actions-recover"> POST </a> </td> <td> <code> /v1/bdbs/{uid}/actions/recover </code> </td> <td> Recover database </td> </tr> </tbody> </table> <h2 id="get-bdbs-actions-recover"> Get recovery plan </h2> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">GET /v1/bdbs/<span class="o">{</span>int: uid<span class="o">}</span>/actions/recover </span></span></code></pre> </div> <p> Fetches the recovery plan for a database. The recovery plan provides information about the recovery status, such as whether recovery is possible, and details on available files to use for recovery. </p> <h4 id="required-permissions"> Required permissions </h4> <table> <thead> <tr> <th> Permission name </th> <th> Roles </th> </tr> </thead> <tbody> <tr> <td> <a href="/docs/latest/operate/rs/references/rest-api/permissions/#view_bdb_recovery_plan"> view_bdb_recovery_plan </a> </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer </td> </tr> </tbody> </table> <h3 id="get-request"> Request </h3> <h4 id="example-http-request"> Example HTTP request </h4> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">GET /bdbs/1/actions/recover </span></span></code></pre> </div> <h4 id="url-parameters"> URL parameters </h4> <table> <thead> <tr> <th> Field </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> uid </td> <td> integer </td> <td> The unique ID of the database. </td> </tr> </tbody> </table> <h3 id="get-response"> Response </h3> <p> Returns a JSON object that represents the database's recovery plan, including recovery files and status. </p> <h4 id="example-response-body"> Example response body </h4> <div class="highlight"> <pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"data_files"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"filename"</span><span class="p">:</span> <span class="s2">"appendonly-1.aof"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"last_modified"</span><span class="p">:</span> <span class="mf">1721164863.8883622</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"node_uid"</span><span class="p">:</span> <span class="s2">"1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"shard_role"</span><span class="p">:</span> <span class="s2">"master"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"shard_slots"</span><span class="p">:</span> <span class="s2">"1-2048"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"shard_uid"</span><span class="p">:</span> <span class="s2">"1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"size"</span><span class="p">:</span> <span class="mi">88</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"filename"</span><span class="p">:</span> <span class="s2">"appendonly-2.aof"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"last_modified"</span><span class="p">:</span> <span class="mf">1721164863.8883622</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"node_uid"</span><span class="p">:</span> <span class="s2">"2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"shard_role"</span><span class="p">:</span> <span class="s2">"slave"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"shard_slots"</span><span class="p">:</span> <span class="s2">"2049-4096"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"shard_uid"</span><span class="p">:</span> <span class="s2">"2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"size"</span><span class="p">:</span> <span class="mi">88</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="nt">"status"</span><span class="p">:</span> <span class="s2">"ready"</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <h4 id="get-status-codes"> Status codes </h4> <table> <thead> <tr> <th> Code </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-200-ok"> 200 OK </a> </td> <td> No error. </td> </tr> <tr> <td> <a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-404-not-found"> 404 Not Found </a> </td> <td> Database UID does not exist. </td> </tr> </tbody> </table> <h2 id="post-bdbs-actions-recover"> Recover database </h2> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">POST /v1/bdbs/<span class="o">{</span>int: uid<span class="o">}</span>/actions/recover </span></span></code></pre> </div> <p> Initiates <a href="/docs/latest/operate/rs/databases/recover/"> recovery for a database </a> in a recoverable state where all the database's files are available after <a href="/docs/latest/operate/rs/clusters/cluster-recovery/"> cluster recovery </a> . </p> <h4 id="required-permissions-1"> Required permissions </h4> <table> <thead> <tr> <th> Permission name </th> <th> Roles </th> </tr> </thead> <tbody> <tr> <td> <a href="/docs/latest/operate/rs/references/rest-api/permissions/#start_bdb_recovery"> start_bdb_recovery </a> </td> <td> admin <br/> cluster_member <br/> db_member </td> </tr> </tbody> </table> <h3 id="post-request"> Request </h3> <p> The request body can either be empty or include a recovery plan. </p> <p> If the request body is empty, the database will be recovered automatically: </p> <ul> <li> <p> Databases with no persistence are recovered with no data. </p> </li> <li> <p> Persistent files such as AOF or RDB will be loaded from their expected storage locations where replica or primary shards were last active. </p> </li> <li> <p> If persistent files are not found where expected but can be located on other cluster nodes, they will be used. </p> </li> </ul> <h4 id="example-http-request-1"> Example HTTP request </h4> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">POST /bdbs/1/actions/recover </span></span></code></pre> </div> <h4 id="example-request-body"> Example request body </h4> <div class="highlight"> <pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"data_files"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"filename"</span><span class="p">:</span> <span class="s2">"appendonly-1.aof"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"node_uid"</span><span class="p">:</span> <span class="s2">"1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"shard_slots"</span><span class="p">:</span> <span class="s2">"1-2048"</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"filename"</span><span class="p">:</span> <span class="s2">"appendonly-2.aof"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"node_uid"</span><span class="p">:</span> <span class="s2">"2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"shard_slots"</span><span class="p">:</span> <span class="s2">"2049-4096"</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="nt">"ignore_errors"</span><span class="p">:</span> <span class="kc">false</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"recover_without_data"</span><span class="p">:</span> <span class="kc">false</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <h4 id="url-parameters-1"> URL parameters </h4> <table> <thead> <tr> <th> Field </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> uid </td> <td> integer </td> <td> The unique ID of the database to recover. </td> </tr> </tbody> </table> <h3 id="post-response"> Response </h3> <p> Returns a status code. Also returns a JSON object with an <code> action_uid </code> in the request body if successful. </p> <h4 id="post-status-codes"> Status codes </h4> <table> <thead> <tr> <th> Code </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-200-ok"> 200 OK </a> </td> <td> The request is accepted and is being processed. When the database is recovered, its status will become <code> active </code> . </td> </tr> <tr> <td> <a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-404-not-found"> 404 Not Found </a> </td> <td> Attempting to perform an action on a nonexistent database. </td> </tr> <tr> <td> <a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-409-conflict"> 409 Conflict </a> </td> <td> Database is currently busy with another action, recovery is already in progress, or is not in a recoverable state. </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/rest-api/requests/bdbs/actions/recover/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/7.4/security/access-control/ldap/enable-role-based-ldap/.html
<section class="prose w-full py-12 max-w-none"> <h1> Enable role-based LDAP </h1> <p class="text-lg -mt-5 mb-10"> Describes how to enable role-based LDAP authentication and authorization using the Cluster Manager UI. </p> <p> Redis Enterprise Software uses a role-based mechanism to enable LDAP authentication and authorization. </p> <p> When a user attempts to access Redis Enterprise resources using LDAP credentials, the credentials are passed to the LDAP server in a bind request. If the request succeeds, the user’s groups are searched for a group that authorizes access to the original resource. </p> <p> Role-based LDAP lets you authorize cluster management users (previously known as <em> external users </em> ) and database users. As with any access control role, you can define the level of access authorized by the role. </p> <h2 id="set-up-ldap-connection"> Set up LDAP connection </h2> <p> To configure and enable LDAP from the Cluster Manager UI: </p> <ol> <li> <p> Go to <strong> Access Control &gt; LDAP &gt; Configuration </strong> . </p> </li> <li> <p> Select <strong> + Create </strong> . </p> </li> <li> <p> In <strong> Set LDAP </strong> , configure <a href="#ldap-server-settings"> LDAP server settings </a> , <a href="#bind-credentials"> bind credentials </a> , <a href="#authentication-query"> authentication query </a> , and <a href="#authorization-query"> authorization query </a> . </p> <a href="/docs/latest/images/rs/screenshots/access-control/ldap-config.png" sdata-lightbox="/images/rs/screenshots/access-control/ldap-config.png"> <img alt="The LDAP configuration screen in the Cluster Manager UI" src="/docs/latest/images/rs/screenshots/access-control/ldap-config.png"/> </a> </li> <li> <p> Select <strong> Save &amp; Enable </strong> . </p> </li> </ol> <h3 id="ldap-server-settings"> LDAP server settings </h3> <p> The <strong> LDAP server </strong> settings define the communication settings used for LDAP authentication and authorization. These include: </p> <table> <thead> <tr> <th style="text-align:left"> <em> Setting </em> </th> <th style="text-align:left"> <em> Description </em> </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> <strong> Protocol type </strong> </td> <td style="text-align:left"> Underlying communication protocol; must be <em> LDAP </em> , <em> LDAPS </em> , or <em> STARTTLS </em> </td> </tr> <tr> <td style="text-align:left"> <strong> Host </strong> </td> <td style="text-align:left"> URL of the LDAP server </td> </tr> <tr> <td style="text-align:left"> <strong> Port </strong> </td> <td style="text-align:left"> LDAP server port number </td> </tr> <tr> <td style="text-align:left"> <strong> Trusted CA certificate </strong> </td> <td style="text-align:left"> <em> (LDAPS or STARTTLS protocols only) </em> Certificate for the trusted certificate authority (CA) </td> </tr> </tbody> </table> <p> When defining multiple LDAP hosts, the organization tree structure must be identical for all hosts. </p> <h3 id="bind-credentials"> Bind credentials </h3> <p> These settings define the credentials for the bind query: </p> <table> <thead> <tr> <th style="text-align:left"> <em> Setting </em> </th> <th style="text-align:left"> <em> Description </em> </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> <strong> Distinguished Name </strong> </td> <td style="text-align:left"> Example: <code> cd=admin,dc=example,dc=org </code> </td> </tr> <tr> <td style="text-align:left"> <strong> Password </strong> </td> <td style="text-align:left"> Example: <code> admin1 </code> </td> </tr> <tr> <td style="text-align:left"> <strong> Client certificate authentication </strong> </td> <td style="text-align:left"> <em> (LDAPS or STARTTLS protocols only) </em> Place checkmark to enable </td> </tr> <tr> <td style="text-align:left"> <strong> Client public key </strong> </td> <td style="text-align:left"> <em> (LDAPS or STARTTLS protocols only) </em> The client public key for authentication </td> </tr> <tr> <td style="text-align:left"> <strong> Client private key </strong> </td> <td style="text-align:left"> <em> (LDAPS or STARTTLS protocols only) </em> The client private key for authentication </td> </tr> </tbody> </table> <h3 id="authentication-query"> Authentication query </h3> <p> These settings define the authentication query: </p> <table> <thead> <tr> <th style="text-align:left"> <em> Setting </em> </th> <th style="text-align:left"> <em> Description </em> </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> <strong> Search user by </strong> </td> <td style="text-align:left"> Either <em> Template </em> or <em> Query </em> </td> </tr> <tr> <td style="text-align:left"> <strong> Template </strong> </td> <td style="text-align:left"> <em> (template search) </em> Example: <code> cn=%u,ou=dev,dc=example,dc=com </code> </td> </tr> <tr> <td style="text-align:left"> <strong> Base </strong> </td> <td style="text-align:left"> <em> (query search) </em> Example: <code> ou=dev,dc=example,dc=com </code> </td> </tr> <tr> <td style="text-align:left"> <strong> Filter </strong> </td> <td style="text-align:left"> <em> (query search) </em> Example: <code> (cn=%u) </code> </td> </tr> <tr> <td style="text-align:left"> <strong> Scope </strong> </td> <td style="text-align:left"> <em> (query search) </em> Must be <em> baseObject </em> , <em> singleLevel </em> , or <em> wholeSubtree </em> </td> </tr> </tbody> </table> <p> In this example, <code> %u </code> is replaced by the username attempting to access the Redis Enterprise resource. </p> <h3 id="authorization-query"> Authorization query </h3> <p> These settings define the group authorization query: </p> <table> <thead> <tr> <th style="text-align:left"> <em> Setting </em> </th> <th style="text-align:left"> <em> Description </em> </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> <strong> Search groups by </strong> </td> <td style="text-align:left"> Either <em> Attribute </em> or <em> Query </em> </td> </tr> <tr> <td style="text-align:left"> <strong> Attribute </strong> </td> <td style="text-align:left"> <em> (attribute search) </em> Example: <code> memberOf </code> (case-sensitive) </td> </tr> <tr> <td style="text-align:left"> <strong> Base </strong> </td> <td style="text-align:left"> <em> (query search) </em> Example: <code> ou=groups,dc=example,dc=com </code> </td> </tr> <tr> <td style="text-align:left"> <strong> Filter </strong> </td> <td style="text-align:left"> <em> (query search) </em> Example: <code> (members=%D) </code> </td> </tr> <tr> <td style="text-align:left"> <strong> Scope </strong> </td> <td style="text-align:left"> <em> (query search) </em> Must be <em> baseObject </em> , <em> singleLevel </em> , or <em> wholeSubtree </em> </td> </tr> </tbody> </table> <p> In this example, <code> %D </code> is replaced by the Distinguished Name of the user attempting to access the Redis Enterprise resource. </p> <h3 id="authentication-timeout"> Authentication timeout </h3> <p> The <strong> Authentication timeout </strong> setting determines the connection timeout to the LDAP server during user authentication. </p> <p> By default, the timeout is 5 seconds, which is recommended for most cases. </p> <p> However, if you enable multi-factor authentication (MFA) for your LDAP server, you might need to increase the timeout to provide enough time for MFA verification. You can set it to any integer in the range of 5-60 seconds. </p> <h2 id="more-info"> More info </h2> <ul> <li> Map LDAP groups to <a href="/docs/latest/operate/rs/7.4/security/access-control/ldap/map-ldap-groups-to-roles/"> access control roles </a> </li> <li> Update database ACLs to <a href="/docs/latest/operate/rs/7.4/security/access-control/ldap/update-database-acls/"> authorize LDAP access </a> </li> <li> Learn more about Redis Software <a href="/docs/latest/operate/rs/7.4/security/"> security and practices </a> </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/security/access-control/ldap/enable-role-based-ldap/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/requests/bdbs/actions/optimize_shards_placement/.html
<section class="prose w-full py-12 max-w-none"> <h1> Optimize shards placement database action requests </h1> <p class="text-lg -mt-5 mb-10"> Optimize shard placement requests </p> <table> <thead> <tr> <th> Method </th> <th> Path </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="#get-bdbs-actions-optimize-shards-placement"> GET </a> </td> <td> <code> /v1/bdbs/{uid}/actions/optimize_shards_placement </code> </td> <td> Get optimized shards placement for a database </td> </tr> </tbody> </table> <h2 id="get-bdbs-actions-optimize-shards-placement"> Get optimized shards placement </h2> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">GET /v1/bdbs/<span class="o">{</span>int: uid<span class="o">}</span>/actions/optimize_shards_placement </span></span></code></pre> </div> <p> Get optimized shards placement for the given database. </p> <h4 id="required-permissions"> Required permissions </h4> <table> <thead> <tr> <th> Permission name </th> <th> Roles </th> </tr> </thead> <tbody> <tr> <td> <a href="/docs/latest/operate/rs/7.4/references/rest-api/permissions/#view_bdb_info"> view_bdb_info </a> </td> <td> admin <br/> cluster_member <br/> cluster_viewer <br/> db_member <br/> db_viewer </td> </tr> </tbody> </table> <h3 id="get-request"> Request </h3> <h4 id="example-http-request"> Example HTTP request </h4> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">GET /bdbs/1/actions/optimize_shards_placement </span></span></code></pre> </div> <h4 id="query-parameters"> Query parameters </h4> <p> Include query parameters in a <code> GET </code> request to generate an optimized shard placement blueprint for a database, using settings that are different from the database's current configuration. </p> <table> <thead> <tr> <th> Field </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> avoid_nodes </td> <td> list of integers </td> <td> Comma-separated list of cluster node IDs to avoid when placing the database’s shards and binding its endpoints (for example, <code> avoid_nodes=1,2 </code> ) </td> </tr> <tr> <td> memory_size </td> <td> integer (default:Β 0) </td> <td> Database memory limit (0 is unlimited), expressed in bytes </td> </tr> <tr> <td> shards_count </td> <td> integer, <nobr> (range: 1-512) </nobr> (default:Β 1) </td> <td> Number of database server-side shards </td> </tr> <tr> <td> shards_placement </td> <td> <code> dense </code> <br/> <code> sparse </code> </td> <td> Control the density of shards <br/> <code> dense </code> : Shards reside on as few nodes as possible <br/> <code> sparse </code> : Shards reside on as many nodes as possible </td> </tr> <tr> <td> bigstore_ram_size </td> <td> integer (default:Β 0) </td> <td> Memory size of bigstore RAM part, expressed in bytes </td> </tr> <tr> <td> replication </td> <td> <code> enabled </code> <br/> <code> disabled </code> </td> <td> In-memory database replication mode </td> </tr> </tbody> </table> <p> The following example request includes <code> shards_count </code> and <code> memory_size </code> as query parameters: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">GET /bdbs/1/actions/optimize_shards_placement?shards_count<span class="o">=</span>10<span class="p">&amp;</span><span class="nv">memory_size</span><span class="o">=</span><span class="m">10000</span> </span></span></code></pre> </div> <h3 id="get-response"> Response </h3> <p> To rearrange the database shards, you can submit the blueprint returned in this response body as the <code> shards_blueprint </code> field in the <a href="#put-bdbs-rearrange-shards"> <code> PUT </code> <code> /bdbs/{uid} </code> </a> request. </p> <h4 id="example-json-body"> Example JSON body </h4> <div class="highlight"> <pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"nodes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"node_uid"</span><span class="p">:</span> <span class="s2">"3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"role"</span><span class="p">:</span> <span class="s2">"master"</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"node_uid"</span><span class="p">:</span> <span class="s2">"1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"role"</span><span class="p">:</span> <span class="s2">"slave"</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="nt">"slot_range"</span><span class="p">:</span> <span class="s2">"5461-10922"</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"nodes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"node_uid"</span><span class="p">:</span> <span class="s2">"3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"role"</span><span class="p">:</span> <span class="s2">"master"</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"node_uid"</span><span class="p">:</span> <span class="s2">"1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"role"</span><span class="p">:</span> <span class="s2">"slave"</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="nt">"slot_range"</span><span class="p">:</span> <span class="s2">"10923-16383"</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"nodes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"node_uid"</span><span class="p">:</span> <span class="s2">"3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"role"</span><span class="p">:</span> <span class="s2">"master"</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"node_uid"</span><span class="p">:</span> <span class="s2">"1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"role"</span><span class="p">:</span> <span class="s2">"slave"</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="nt">"slot_range"</span><span class="p">:</span> <span class="s2">"0-5460"</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">]</span> </span></span></code></pre> </div> <h4 id="headers"> Headers </h4> <table> <thead> <tr> <th> Key </th> <th> Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> Content-Length </td> <td> 352 </td> <td> Length of the request body in octets </td> </tr> <tr> <td> cluster-state-id </td> <td> 30 </td> <td> Cluster state ID </td> </tr> </tbody> </table> <h4 id="get-status-codes"> Status codes </h4> <table> <thead> <tr> <th> Code </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1"> 200 OK </a> </td> <td> No error </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5"> 404 Not Found </a> </td> <td> Database UID does not exist </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.7"> 406 Not Acceptable </a> </td> <td> Not enough resources in the cluster to host the database </td> </tr> </tbody> </table> <h2 id="put-bdbs-rearrange-shards"> Rearrange database shards </h2> <p> Use the blueprint returned by the <a href="/docs/latest/operate/rs/7.4/references/rest-api/requests/bdbs/actions/optimize_shards_placement/#get-bdbs-actions-optimize-shards-placement"> <code> GET </code> <code> /bdbs/{uid}/actions/optimize_shards_placement </code> </a> request as the value of the <code> shards_blueprint </code> field to rearrange the database shards. </p> <p> To ensure that the optimized shard placement is relevant for the current cluster state, pass the <code> cluster-state-id </code> , taken from the response header of the <code> GET </code> request, in the <a href="/docs/latest/operate/rs/7.4/references/rest-api/requests/bdbs/#put-bdbs"> <code> PUT </code> <code> /bdbs/{uid} </code> </a> request headers. </p> <p> The cluster will reject the update if its state was changed since the optimal shards placement was obtained. </p> <h3 id="request"> Request </h3> <h4 id="example-http-request-1"> Example HTTP request </h4> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">PUT /bdbs/1 </span></span></code></pre> </div> <h4 id="headers-1"> Headers </h4> <table> <thead> <tr> <th> Key </th> <th> Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> Host </td> <td> cnm.cluster.fqdn </td> <td> Domain name </td> </tr> <tr> <td> Accept </td> <td> application/json </td> <td> Accepted media type </td> </tr> <tr> <td> cluster-state-id </td> <td> 30 </td> <td> Cluster state ID </td> </tr> </tbody> </table> <h4 id="example-json-body-1"> Example JSON body </h4> <div class="highlight"> <pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"shards_blueprint"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"nodes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"node_uid"</span><span class="p">:</span> <span class="s2">"2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"role"</span><span class="p">:</span> <span class="s2">"master"</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="nt">"slot_range"</span><span class="p">:</span> <span class="s2">"0-8191"</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"..."</span> </span></span><span class="line"><span class="cl"> <span class="p">]</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Warning: </div> If you submit such an optimized blueprint, it may cause strain on the cluster and its resources. Use with caution. </div> </div> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/requests/bdbs/actions/optimize_shards_placement/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisgraph/redisgraph-2.0-release-notes.md.html
<section class="prose w-full py-12 max-w-none"> <h1> RedisGraph 2.0 release notes </h1> <p class="text-lg -mt-5 mb-10"> Enabled graph-aided search and graph visualisation. Cypher coverage. Performance improvements. </p> <h2 id="requirements"> Requirements </h2> <p> RedisGraph v2.0.21 requires: </p> <ul> <li> Minimum Redis compatibility version (database): 5.0.7 </li> <li> Minimum Redis Enterprise Software version (cluster): 5.4.11 </li> </ul> <h2 id="v2021-october-2020"> v2.0.21 (October 2020) </h2> <p> This is a maintenance release for version 2.0. </p> <p> Headlines: </p> <ul> <li> This release improves overall stability and provides fixes for issues found after the previous release. </li> </ul> <p> Details: </p> <ul> <li> <p> Minor enhancements: </p> <ul> <li> # <a href="https://github.com/RedisGraph/RedisGraph/pull/1326"> 1326 </a> , # <a href="https://github.com/RedisGraph/RedisGraph/pull/1330"> 1330 </a> Enable comments in Cypher queries. </li> </ul> </li> <li> <p> Bug fixes: </p> </li> <li> <p> # <a href="https://github.com/RedisGraph/RedisGraph/pull/1338"> 1338 </a> Update parser to support negative values. </p> </li> <li> <p> # <a href="https://github.com/RedisGraph/RedisGraph/pull/1319"> 1319 </a> Replace assertion with runtime error - execution plan building process is unable locate an operation suitable for a filter. </p> </li> <li> <p> # <a href="https://github.com/RedisGraph/RedisGraph/pull/1184"> 1184 </a> EXPLAIN and PROFILE are invalid clauses. They have counterpart commands <code> GRAPH.EXPLAIN </code> and <code> GRAPH.PROFILE </code> </p> </li> <li> <p> # <a href="https://github.com/RedisGraph/RedisGraph/pull/1212"> 1212 </a> Emit error on the creation of undirected edges. </p> </li> </ul> <h2 id="v2020-september-2020"> v2.0.20 (September 2020) </h2> <p> This is a maintenance release for version 2.0. </p> <p> Headlines: </p> <ul> <li> This release improves overall stability and provides fixes for issues found after the previous release. </li> </ul> <p> Details: </p> <ul> <li> <p> Minor updates: </p> <ul> <li> # <a href="https://github.com/RedisGraph/RedisGraph/pull/1315"> 1315 </a> RediSearch 1.8.3 </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/pull/1276"> 1276 </a> Graph info is added to Redis crash report. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/pull/1265"> 1265 </a> Debug assertion functionality. </li> </ul> </li> </ul> <h2 id="v2019-august-2020"> v2.0.19 (August 2020) </h2> <p> This is a maintenance release for version 2.0. </p> <p> Headlines: </p> <ul> <li> This release improves overall stability and provides fixes for issues found after the previous release. </li> </ul> <p> Details: </p> <ul> <li> Minor updates: <ul> <li> # <a href="https://github.com/RedisGraph/RedisGraph/pull/1229"> 1229 </a> Upgrade RediSearch dependency to 1.8.2 </li> </ul> </li> <li> Performance enhancements: <ul> <li> # <a href="https://github.com/RedisGraph/RedisGraph/pull/1218"> 1218 </a> Enable parameters support for ID-based entity retrieval </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/pull/1242"> 1242 </a> Improve update logic, update RediSearch indices only once per update </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/pull/1226"> 1226 </a> Let RediSearch perform document deletion when replacing a document </li> </ul> </li> <li> Bug Fixes: <ul> <li> # <a href="https://github.com/RedisGraph/RedisGraph/pull/1223"> 1223 </a> Resolve race condition in accessing/updating attribute maps. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/pull/1196"> 1196 </a> Enable RediSearch <a href="/docs/latest/develop/interact/search-and-query/administration/gc/"> Garbage Collection </a> </li> </ul> </li> </ul> <h2 id="v2015-25-june-2020"> v2.0.15 (25 June 2020) </h2> <p> This is a maintenance release for version 2.0. </p> <p> Headlines: </p> <ul> <li> This release improves overall stability and provides fixes for issues found after the previous release. </li> </ul> <p> Details: </p> <ul> <li> Bug Fixes: <ul> <li> # <a href="https://github.com/RedisGraph/RedisGraph/pull/1159"> 1159 </a> <code> IN </code> operator didn't result in an index array lookup with parameterised array ( <code> IN $param </code> ). </li> </ul> </li> </ul> <h2 id="v2014-22-june-2020"> v2.0.14 (22 June 2020) </h2> <p> This is a maintenance release for version 2.0. </p> <p> Headlines: </p> <ul> <li> This release improves overall stability and provides fixes for issues found after the previous release. </li> </ul> <p> Details: </p> <ul> <li> Bug Fixes: <ul> <li> # <a href="https://github.com/RedisGraph/RedisGraph/pull/1157"> 1157 </a> Index search not using query parameters. </li> </ul> </li> </ul> <h2 id="v2013-15-june-2020"> v2.0.13 (15 June 2020) </h2> <p> This is a maintenance release for version 2.0. </p> <p> Headlines: </p> <ul> <li> This release improves overall stability and provides fixes for issues found after the previous release. </li> </ul> <p> Details: </p> <ul> <li> Enhancements: <ul> <li> # <a href="https://github.com/RedisGraph/RedisGraph/pull/1118"> 1118 </a> Added module configuration parameters for the number of threads in OpenMP and concurrent queries. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/pull/1121"> 1121 </a> <a href="https://github.com/RediSearch/RediSearch/"> RediSearch </a> v1.8.1 </li> </ul> </li> </ul> <h2 id="v2012-may-2020"> v2.0.12 (May 2020) </h2> <p> This is a maintenance release for version 2.0. </p> <p> Headlines: </p> <ul> <li> This release improves overall stability and provides fixes for issues found after the previous release. </li> </ul> <p> Details: </p> <ul> <li> Enhancements: <ul> <li> # <a href="https://github.com/RedisGraph/RedisGraph/pull/1103"> 1103 </a> RediSearch 1.8. This upgrade will reduce the resources required for Garbage Collection of indices inside RedisGraph. </li> </ul> </li> </ul> <h2 id="v2011-april-2020"> v2.0.11 (April 2020) </h2> <p> This is a maintenance release for version 2.0. </p> <p> Headlines: </p> <ul> <li> This release improves overall stability and provides fixes for issues found after the previous release. </li> </ul> <p> Details: </p> <ul> <li> Minor Enhancements: <ul> <li> # <a href="https://github.com/RedisGraph/RedisGraph/pull/1056"> 1056 </a> Added <code> DISTINCT </code> support for paths and arrays. </li> </ul> </li> <li> Minor Bugfixes: <ul> <li> # <a href="https://github.com/RedisGraph/RedisGraph/pull/1056"> 1056 </a> Streamlined logic for uniquing entities. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/pull/1056"> 1056 </a> Enabled comparison routine for paths. </li> </ul> </li> </ul> <h2 id="v2010-29-march-2020"> v2.0.10 (29 March 2020) </h2> <p> Headlines: </p> <ul> <li> This release improves overall stability and provides fixes for issues found after the previous release. </li> </ul> <p> Details: </p> <ul> <li> Minor Enhancements: <ul> <li> # <a href="https://github.com/redisgraph/redisgraph/issues/1035"> 1035 </a> - RediSearch version <a href="https://github.com/RediSearch/RediSearch/releases/tag/v1.6.11"> 1.6.11 </a> . </li> </ul> </li> <li> Bugfixes: <ul> <li> # <a href="https://github.com/redisgraph/redisgraph/issues/1017"> 1017 </a> , # <a href="https://github.com/redisgraph/redisgraph/issues/1019"> 1019 </a> - Algebraic expressions correctness. </li> <li> # <a href="https://github.com/redisgraph/redisgraph/issues/1020"> 1020 </a> - Support parameterised SKIP and LIMIT. </li> </ul> </li> </ul> <h2 id="v209-19-march-2020"> v2.0.9 (19 March 2020) </h2> <p> Headlines: </p> <ul> <li> This release improves overall stability and provides fixes for issues found after the previous release. </li> </ul> <p> Details: </p> <ul> <li> Bugfixes: <ul> <li> # <a href="https://github.com/redisgraph/redisgraph/issues/1028"> 1028 </a> Ensure proper placement of Index Scans when partially replacing Filter ops. </li> </ul> </li> </ul> <h2 id="v208-18-march-2020"> v2.0.8 (18 March 2020) </h2> <p> Headlines: </p> <ul> <li> This release improves overall stability and provides fixes for issues found after the previous release. </li> </ul> <p> Details: </p> <ul> <li> Bugfixes: <ul> <li> # <a href="https://github.com/redisgraph/redisgraph/issues/1023"> 1023 </a> Fix regression in checking argument counts to GRAPH endpoints. </li> </ul> </li> </ul> <h2 id="v206-15-march-2020"> v2.0.6 (15 March 2020) </h2> <p> Headlines: </p> <ul> <li> This release improves overall stability and provides fixes for issues found after the previous release. </li> </ul> <p> Details: </p> <ul> <li> # <a href="https://github.com/redisgraph/redisgraph/issues/897"> 897 </a> GRAPH.SLOWLOG </li> <li> # <a href="https://github.com/redisgraph/redisgraph/issues/1004"> 1004 </a> Re-enable GRAPH.PROFILE </li> <li> # <a href="https://github.com/redisgraph/redisgraph/issues/917"> 917 </a> , # <a href="https://github.com/redisgraph/redisgraph/issues/991"> 991 </a> , # <a href="https://github.com/redisgraph/redisgraph/issues/940"> 940 </a> , # <a href="https://github.com/redisgraph/redisgraph/issues/984"> 984 </a> Memory leak fixes </li> <li> # <a href="https://github.com/redisgraph/redisgraph/issues/925"> 925 </a> Bug fix within RediSearch </li> <li> # <a href="https://github.com/redisgraph/redisgraph/issues/1001"> 1001 </a> Bug fix label scan invalid range </li> </ul> <h2 id="v205-23-february-2020"> v2.0.5 (23 February 2020) </h2> <p> Headlines: </p> <ul> <li> This release improves overall stability and provides fixes for issues found after the previous release. </li> </ul> <p> Details: </p> <ul> <li> Enhancement: <ul> <li> # <a href="https://github.com/redisgraph/redisgraph/issues/955"> 955 </a> Switch OR,AND boolean semiring to ANY,PAIR. </li> </ul> </li> </ul> <h2 id="v204-23-february-2020"> v2.0.4 (23 February 2020) </h2> <p> Details: </p> <ul> <li> Enhancement: <ul> <li> Reduce GraphBLAS size </li> </ul> </li> </ul> <h2 id="v202-23-february-2020"> v2.0.2 (23 February 2020) </h2> <p> Headlines: </p> <ul> <li> This release improves overall stability and provides fixes for issues found after the previous release. </li> </ul> <p> Details: </p> <ul> <li> Improved error reporting: <ul> <li> # <a href="https://github.com/redisgraph/redisgraph/issues/925"> 925 </a> RediSearch query error reporting </li> <li> # <a href="https://github.com/redisgraph/redisgraph/issues/919"> 919 </a> Added non existing entity runtime error </li> </ul> </li> <li> Enhancements: <ul> <li> # <a href="https://github.com/redisgraph/redisgraph/issues/942"> 942 </a> Update GraphBLAS version (3.2.0) </li> <li> # <a href="https://github.com/redisgraph/redisgraph/issues/922"> 922 </a> Filter tree compaction </li> <li> # <a href="https://github.com/redisgraph/redisgraph/issues/906"> 906 </a> Optimize cartesian product </li> <li> # <a href="https://github.com/redisgraph/redisgraph/issues/898"> 898 </a> Granular matrix locking </li> </ul> </li> <li> Bug fixes: <ul> <li> # <a href="https://github.com/redisgraph/redisgraph/issues/917"> 917 </a> # <a href="https://github.com/redisgraph/redisgraph/issues/940"> 940 </a> Resolve memory leaks </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/pull/938"> 938 </a> Label matrix should be fetch right before eval </li> </ul> </li> </ul> <h2 id="v20-ga-201---january-2020"> v2.0 GA (2.0.1 - January 2020) </h2> <p> This is the General Availability (GA) release of RedisGraph 2.0 (2.0.1)! </p> <p> Headlines: </p> <ul> <li> Full Text Search (FTS) enabling Graph-aided Search. </li> <li> Full graph response enabling visualisation. </li> <li> Substantial amount of Cypher coverage. </li> <li> Performance improvements of up to 4x compared to RedisGraph 1.2. </li> </ul> <p> (We will blog about this release soon including performance improvements results and the link here) </p> <p> Full details: </p> <ul> <li> Major features <ul> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/339"> 339 </a> Full Graph Response. RedisGraph now allows to return Graph entities such as Nodes and Relationships. This feature also enables graph visualisation. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/558"> 558 </a> Indexing functionality replaced by <a href="redisearch.io"> RediSearch </a> . This results in support for <ul> <li> compound indices </li> <li> full text search </li> <li> graph-aided search </li> </ul> </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/691"> 691 </a> RediSearch index is used with <code> IN </code> operator on indexed properties. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/488"> 488 </a> Replace flex/lemon parser with <a href="https://github.com/cleishm/libcypher-parser"> libcypher-parser </a> . </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/574"> 574 </a> Introduction of the array data type. This introduces significant support of Cypher as well as properties can be arrays on both nodes and relationships. </li> <li> Cypher <ul> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/714"> 714 </a> <code> MERGE </code> can be combined with any other clause. <code> MERGE </code> will take into account bounded entities. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/786"> 786 </a> Support for passing all supported graph data types (Node, Relationship, Array,...) as arguments to procedure calls, rather than requiring all arguments to be Strings. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/708"> 708 </a> Named path support. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/717"> 717 </a> <code> count(*) </code> </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/730"> 730 </a> <code> UNION </code> </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/757"> 757 </a> <code> coalesce </code> </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/658"> 658 </a> Support for <code> COUNT DISTINCT </code> </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/574"> 574 </a> with the array data support comes <code> IN </code> , <code> collect </code> , <code> head </code> , <code> range </code> , <code> reverse </code> , <code> size </code> , <code> tail </code> </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/624"> 624 </a> <code> randomUUID() </code> </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/632"> 632 </a> <code> IS NULL </code> and <code> IS NOT NULL </code> . </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/594"> 594 </a> Support dynamic inline properties for <code> CREATE </code> and <code> MERGE </code> patterns. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/583"> 583 </a> <code> NOT </code> Operator. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/569"> 569 </a> <code> timestamp() </code> function. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/586"> 586 </a> <code> CASE WHEN </code> (simple form). </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/582"> 582 </a> <code> contains </code> function. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/596"> 596 </a> <code> indegree </code> and <code> outdegree </code> functions for nodes. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/587"> 587 </a> improved boolean logic. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/539"> 539 </a> Reusable entities in pattern matching. </li> </ul> </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/668"> 668 </a> PageRank support. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/713"> 713 </a> Parameterised queries support. Most client drivers are updated. This enables future performance enhancements for query caching. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/662"> 662 </a> Support for AOF. </li> </ul> </li> <li> Enhancements <ul> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/752"> 752 </a> Use GraphBLAS 3.1.1. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/674"> 674 </a> <code> GRAPH.QUERY </code> will not fail even if graph doesn't exist. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/613"> 613 </a> Runtime arithmetic error handling. </li> </ul> </li> <li> Performance Improvements <ul> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/773"> 773 </a> Bulk deletion of relationships. Deletion of relationships within the same query will be efficiently handled by batch operations in GraphBLAS. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/783"> 783 </a> Better replication support. Only write queries that mutate the graph or create indices will be replicated to AOF and slaves. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/783"> 783 </a> Better commit flow. The Redis Global Lock and RedisGraphs's R/W lock are released once writes are done. Fixed duplicate replications in queries with multiple write segments. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/640"> 640 </a> GraphBlas to support OpenMP. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/532"> 532 </a> # <a href="https://github.com/RedisGraph/RedisGraph/issues/535"> 535 </a> Counting edges of given type by reducing matrices. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/534"> 534 </a> # <a href="https://github.com/RedisGraph/RedisGraph/issues/571"> 571 </a> Query parsing and <code> GRAPH.EXPLAIN </code> in dedicated thread. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/550"> 550 </a> # <a href="https://github.com/RedisGraph/RedisGraph/issues/555"> 555 </a> Optimize cartesian product by reducing to join. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/641"> 641 </a> Cartesian products with multiple incoming streams &gt;2 can now be optimized with "HashJoin". </li> </ul> </li> <li> Bugfixes <ul> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/783"> 783 </a> Master-replica replication - slaves were dropping index mutations caused by procedure calls. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/785"> 785 </a> Solved several major memory leaks. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/795"> 795 </a> The underlying graph object's attributes were not updated on <code> RENAME </code> . </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/720"> 720 </a> Validation of function calls in <code> WITH </code> and <code> CREATE </code> clauses e.g. <code> CREATE (a {v: fake()}) </code> . </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/732"> 732 </a> , # <a href="https://github.com/RedisGraph/RedisGraph/issues/736"> 736 </a> , # <a href="https://github.com/RedisGraph/RedisGraph/issues/747"> 747 </a> Detect cycles in graph and generate algebraic expression. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/734"> 734 </a> Fix access of uninitialised GrB_Info. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/735"> 735 </a> Index scans with <code> IN </code> filters did not compare with strings properly, </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/758"> 758 </a> Validate that during <code> UNION </code> all return clauses are annotated. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/412"> 412 </a> Better handling for <code> GRAPH.DELETE </code> . </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/537"> 537 </a> Wrong row index within expand-into, enabled few TCK tests. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/591"> 591 </a> Emit validation error when an alias refers to both nodes and edges. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/606"> 606 </a> Fix Record ID of edges held in ExpandInto op. </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/607"> 607 </a> All ops NULL-set variables in their free routines (memory). </li> <li> # <a href="https://github.com/RedisGraph/RedisGraph/issues/893"> 893 </a> Preserve the children array order when replacing operations. </li> </ul> </li> </ul> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> The version inside Redis will be 20001 or 2.0.1 in semantic versioning. </div> </div> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisgraph/redisgraph-2.0-release-notes/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/databases/recover/.html
<section class="prose w-full py-12 max-w-none"> <h1> Recover a failed database </h1> <p class="text-lg -mt-5 mb-10"> Recover a database after the cluster fails or the database is corrupted. </p> <p> When a cluster fails or a database is corrupted, you must: </p> <ol> <li> <a href="/docs/latest/operate/rs/clusters/cluster-recovery/"> Restore the cluster configuration </a> from the CCS files </li> <li> Recover the databases with their previous configuration and data </li> </ol> <p> To restore data to databases in the new cluster, you must restore the database persistence files (backup, AOF, or snapshot files) to the databases. These files are stored in the <a href="/docs/latest/operate/rs/installing-upgrading/install/plan-deployment/persistent-ephemeral-storage/"> persistence storage location </a> . </p> <p> The database recovery process includes: </p> <ol> <li> If the cluster failed, <a href="/docs/latest/operate/rs/clusters/cluster-recovery/"> recover the cluster </a> . </li> <li> Identify recoverable databases. </li> <li> Restore the database data. </li> <li> Verify that the databases are active. </li> </ol> <h2 id="prerequisites"> Prerequisites </h2> <ul> <li> <p> Before you start database recovery, make sure that the cluster that hosts the database is healthy. In the case of a cluster failure, you must <a href="/docs/latest/operate/rs/clusters/cluster-recovery/"> recover the cluster </a> before you recover the databases. </p> </li> <li> <p> We recommend that you allocate new persistent storage drives for the new cluster nodes. If you use the original storage drives, make sure to back up all files on the old persistent storage drives to another location. </p> </li> </ul> <h2 id="recover-databases"> Recover databases </h2> <p> After you prepare the cluster that hosts the database, you can run the recovery process from the <a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/"> <code> rladmin </code> </a> command-line interface (CLI). </p> <p> To recover the database: </p> <ol> <li> <p> Mount the persistent storage drives with the recovery files to the new nodes. These drives must contain the cluster configuration backup files and database persistence files. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> Make sure that the user <code> redislabs </code> has permissions to access the storage location of the configuration and persistence files on each of the nodes. </div> </div> <p> If you use local persistent storage, place all of the recovery files on each of the cluster nodes. </p> </li> <li> <p> To see which databases are recoverable, run: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladminΒ recover list </span></span></code></pre> </div> <p> The status for each database can be either ready for recovery or missing files. An indication of missing files in any of the databases can result from: </p> <ul> <li> The storage location is not found - Make sure the recovery path is set correctly on all nodes in the cluster. </li> <li> Files are not found in the storage location - Move the files to the storage location. </li> <li> No permission to read the files - Change the file permissions so that redislabs:redislabs has 640 permissions. </li> <li> Files are corrupted - Locate copies of the files that are not corrupted. </li> </ul> <p> If you cannot resolve the issues, contact <a href="https://redis.com/company/support/"> Redis support </a> . </p> </li> <li> <p> Recover the database using one of the following <a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/recover/"> <code> rladmin recover </code> </a> commands: </p> <ul> <li> <p> Recover all databases from the persistence files located in the persistent storage drives: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin recover all </span></span></code></pre> </div> </li> <li> <p> Recover a single database from the persistence files located in the persistent storage drives: </p> <ul> <li> <p> By database ID: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin recover db db:&lt;id&gt; </span></span></code></pre> </div> </li> <li> <p> By database name: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin recover db &lt;name&gt; </span></span></code></pre> </div> </li> </ul> </li> <li> <p> Recover only the database configuration for a single database (without the data): </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin recover db &lt;name&gt; only_configuration </span></span></code></pre> </div> </li> </ul> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> <ul> <li> If persistence was not configured for the database, the database is restored empty. </li> <li> For Active-Active databases that still have live instances, we recommend that you recover the configuration for the failed instances and let the data update from the other instances. </li> <li> For Active-Active databases where all instances need to be recovered, we recommend you recover one instance with the data and only recover the configuration for the other instances. The empty instances then update from the recovered data. </li> <li> If the persistence files of the databases from the old cluster are not stored in the persistent storage location of the new node, you must first map the recovery path of each node to the location of the old persistence files. To do this, run the <code> node &lt;id&gt; recovery_path set </code> command in rladmin. The persistence files for each database are located in the persistent storage path of the nodes from the old cluster, usually under <code> /var/opt/redislabs/persist/redis </code> . </li> </ul> </div> </div> </li> <li> <p> To verify that the recovered databases are now active, run: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin status </span></span></code></pre> </div> </li> </ol> <p> After the databases are recovered, make sure your Redis clients can successfully connect to the databases. </p> <h2 id="configure-automatic-recovery"> Configure automatic recovery </h2> <p> If you enable the automatic recovery cluster policy, Redis Enterprise tries to quickly recover as much data as possible from before the disaster. </p> <p> To enable automatic recovery, <a href="/docs/latest/operate/rs/references/rest-api/requests/cluster/policy/#put-cluster-policy"> update the cluster policy </a> using the REST API: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">PUT /v1/cluster/policy </span></span><span class="line"><span class="cl"><span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"auto_recovery"</span>: <span class="nb">true</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <p> Redis Enterprise tries to recover databases from the best existing persistence files. If a persistence file isn't available, which can happen if its host node is down, the automatic recovery process waits for it to become available. </p> <p> For each database, you can set the <code> recovery_wait_time </code> to define how many seconds the database waits for a persistence file to become available before recovery. After the wait time elapses, the recovery process continues, which can result in partial or full data loss. The default value is <code> -1 </code> , which means to wait forever. Short wait times can increase the risk of potential data loss. </p> <p> To change <code> recovery_wait_time </code> for an existing database using the REST API: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">PUT /v1/bdbs/&lt;bdb_uid&gt; </span></span><span class="line"><span class="cl"><span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"recovery_wait_time"</span>: <span class="m">3600</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <p> You can also set <code> recovery_wait_time </code> when you <a href="/docs/latest/operate/rs/references/rest-api/requests/bdbs/#post-bdbs-v1"> create a database </a> using the REST API. </p> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/databases/recover/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/ft.dictadd.html
<section class="prose w-full py-12"> <h1 class="command-name"> FT.DICTADD </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">FT.DICTADD dict term [term ...] </pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available in: </dt> <dd class="m-0"> <a href="/docs/stack"> Redis Stack </a> / <a href="/docs/interact/search-and-query"> Search 1.4.0 </a> </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) </dd> </dl> <p> Add terms to a dictionary </p> <p> <a href="#examples"> Examples </a> </p> <h2 id="required-arguments"> Required arguments </h2> <details open=""> <summary> <code> dict </code> </summary> <p> is dictionary name. </p> </details> <details open=""> <summary> <code> term </code> </summary> <p> term to add to the dictionary. </p> </details> <h2 id="return"> Return </h2> <p> FT.DICTADD returns an integer reply, the number of new terms that were added. </p> <h2 id="examples"> Examples </h2> <details open=""> <summary> <b> Add terms to a dictionary </b> </summary> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379&gt; FT.DICTADD dict foo bar <span class="s2">"hello world"</span> </span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">3</span></span></span></code></pre> </div> </details> <h2 id="see-also"> See also </h2> <p> <a href="/docs/latest/commands/ft.dictdel/"> <code> FT.DICTDEL </code> </a> | <a href="/docs/latest/commands/ft.dictdump/"> <code> FT.DICTDUMP </code> </a> </p> <h2 id="related-topics"> Related topics </h2> <p> <a href="/docs/latest/develop/interact/search-and-query/"> RediSearch </a> </p> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/ft.dictadd/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/latency/.html
<section class="prose w-full py-12"> <h1 class="command-name"> LATENCY </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">LATENCY</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 2.8.13 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> Depends on subcommand. </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @slow </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> This is a container command for latency diagnostics commands. </p> <p> To see the list of available commands you can call <a href="/docs/latest/commands/latency-help/"> <code> LATENCY HELP </code> </a> . </p> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/latency/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/groupsorted-set.html
<section class="prose w-full py-12"> <h1> Commands </h1> </section>
https://redis.io/docs/latest/commands/client-getname/.html
<section class="prose w-full py-12"> <h1 class="command-name"> CLIENT GETNAME </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">CLIENT GETNAME</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 2.6.9 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @slow </code> <span class="mr-1 last:hidden"> , </span> <code> @connection </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> The <code> CLIENT GETNAME </code> returns the name of the current connection as set by <a href="/docs/latest/commands/client-setname/"> <code> CLIENT SETNAME </code> </a> . Since every new connection starts without an associated name, if no name was assigned a null bulk reply is returned. </p> <h2 id="resp2-reply"> RESP2 Reply </h2> <p> One of the following: </p> <ul> <li> <a href="../../develop/reference/protocol-spec#bulk-strings"> Bulk string reply </a> : the connection name of the current connection. </li> <li> <a href="../../develop/reference/protocol-spec#bulk-strings"> Nil reply </a> : the connection name was not set. </li> </ul> <h2 id="resp3-reply"> RESP3 Reply </h2> <p> One of the following: </p> <ul> <li> <a href="../../develop/reference/protocol-spec#bulk-strings"> Bulk string reply </a> : the connection name of the current connection. </li> <li> <a href="../../develop/reference/protocol-spec#nulls"> Null reply </a> : the connection name was not set. </li> </ul> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/client-getname/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/bf.loadchunk/.html
<section class="prose w-full py-12"> <h1 class="command-name"> BF.LOADCHUNK </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">BF.LOADCHUNK key iterator data</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available in: </dt> <dd class="m-0"> <a href="/docs/stack"> Redis Stack </a> / <a href="/docs/data-types/probabilistic"> Bloom 1.0.0 </a> </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(n), where n is the capacity </dd> </dl> <p> Restores a Bloom filter previously saved using <a href="/docs/latest/commands/bf.scandump/"> <code> BF.SCANDUMP </code> </a> . </p> <p> See the <a href="/docs/latest/commands/bf.scandump/"> <code> BF.SCANDUMP </code> </a> command for example usage. </p> <p> <note> <b> Notes </b> </note> </p> <ul> <li> This command overwrites the Bloom filter stored under <code> key </code> . </li> <li> Make sure that the Bloom filter is not changed between invocations. </li> </ul> <h2 id="required-arguments"> Required arguments </h2> <details open=""> <summary> <code> key </code> </summary> <p> is key name for a Bloom filter to restore. </p> </details> <details open=""> <summary> <code> iterator </code> </summary> <p> Iterator value associated with <code> data </code> (returned by <a href="/docs/latest/commands/bf.scandump/"> <code> BF.SCANDUMP </code> </a> ) </p> </details> <details open=""> <summary> <code> data </code> </summary> <p> Current data chunk (returned by <a href="/docs/latest/commands/bf.scandump/"> <code> BF.SCANDUMP </code> </a> ) </p> </details> <h2 id="return-value"> Return value </h2> <p> Returns one of these replies: </p> <ul> <li> <a href="/docs/latest/develop/reference/protocol-spec/#simple-strings"> Simple string reply </a> - <code> OK </code> if executed correctly </li> <li> [] on error (invalid arguments, wrong key type, wrong data, etc.) </li> </ul> <h2 id="examples"> Examples </h2> <p> See <a href="/docs/latest/commands/bf.scandump/"> <code> BF.SCANDUMP </code> </a> for an example. </p> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/bf.loadchunk/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/ft._list.html
<section class="prose w-full py-12"> <h1 class="command-name"> FT._LIST </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">FT._LIST</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available in: </dt> <dd class="m-0"> <a href="/docs/stack"> Redis Stack </a> / <a href="/docs/interact/search-and-query"> Search 2.0.0 </a> </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) </dd> </dl> <p> Returns a list of all existing indexes. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Temporary command: </div> <p> The prefix <code> _ </code> in the command indicates, this is a temporary command. </p> <p> In the future, a <a href="/docs/latest/commands/scan/"> <code> SCAN </code> </a> type of command will be added, for use when a database contains a large number of indices. </p> </div> </div> <h2 id="return"> Return </h2> <p> <a href="/docs/latest/develop/reference/protocol-spec/#arrays"> Array reply </a> with index names. </p> <h2 id="examples"> Examples </h2> <div class="highlight"> <pre class="chroma"><code class="language-sql" data-lang="sql"><span class="line"><span class="cl"><span class="n">FT</span><span class="p">.</span><span class="n">_LIST</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="mi">1</span><span class="p">)</span><span class="w"> </span><span class="s2">"idx"</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="mi">2</span><span class="p">)</span><span class="w"> </span><span class="s2">"movies"</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="mi">3</span><span class="p">)</span><span class="w"> </span><span class="s2">"imdb"</span><span class="w"> </span></span></span></code></pre> </div> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/ft._list/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/develop/data-types/probabilistic/t-digest/.html
<section class="prose w-full py-12"> <h1> t-digest </h1> <p class="text-lg -mt-5 mb-10"> t-digest is a probabilistic data structure that allows you to estimate the percentile of a data stream. </p> <p> The t-digest is a sketch data structure in Redis Stack for estimating percentiles from a data stream or a large dataset using a compact sketch. </p> <p> It can answer questions like: </p> <ul> <li> Which fraction of the values in the data stream are smaller than a given value? </li> <li> How many values in the data stream are smaller than a given value? </li> <li> What's the highest value that's smaller than <em> p </em> percent of the values in the data stream? (what is the p-percentile value)? </li> </ul> <h3 id="what-is-t-digest"> What is t-digest? </h3> <p> t-digest is a data structure that will estimate a percentile point without having to store and order all the data points in a set. For example: to answer the question "What's the average latency for 99% of my database operations" we would have to store the average latency for every user, order the values, cut out the last 1% and only then find the average value of all the rest. This kind of process is costly not just in terms of the processing needed to order those values but also in terms of the space needed to store them. Those are precisely the problems t-digest solves. </p> <p> t-digest can also be used to estimate other values related to percentiles, like trimmed means. </p> <blockquote> <p> A <strong> trimmed mean </strong> is the mean value from the sketch, excluding observation values outside the low and high cutoff percentiles. For example, a 0.1 trimmed mean is the mean value of the sketch, excluding the lowest 10% and the highest 10% of the values. </p> </blockquote> <h2 id="use-cases"> Use cases </h2> <p> <strong> Hardware/software monitoring </strong> </p> <p> You measure your online server response latency, and you like to query: </p> <ul> <li> <p> What are the 50th, 90th, and 99th percentiles of the measured latencies? </p> </li> <li> <p> Which fraction of the measured latencies are less than 25 milliseconds? </p> </li> <li> <p> What is the mean latency, ignoring outliers? or What is the mean latency between the 10th and the 90th percentile? </p> </li> </ul> <p> <strong> Online gaming </strong> </p> <p> Millions of people are playing a game on your online gaming platform, and you want to give the following information to each player? </p> <ul> <li> <p> Your score is better than x percent of the game sessions played. </p> </li> <li> <p> There were about y game sessions where people scored larger than you. </p> </li> <li> <p> To have a better score than 90% of the games played, your score should be z. </p> </li> </ul> <p> <strong> Network traffic monitoring </strong> </p> <p> You measure the IP packets transferred over your network each second and try to detect denial-of-service attacks by asking: </p> <ul> <li> <p> Does the number of packets in the last second exceed 99% of previously observed values? </p> </li> <li> <p> How many packets do I expect to see under <em> normal </em> network conditions? (Answer: between x and y, where x represents the 1st percentile and y represents the 99th percentile). </p> </li> </ul> <p> <strong> Predictive maintenance </strong> </p> <ul> <li> <p> Was the measured parameter (noise level, current consumption, etc.) irregular? (not within the [1st percentile...99th percentile] range)? </p> </li> <li> <p> To which values should I set my alerts? </p> </li> </ul> <h2 id="examples"> Examples </h2> <p> In the following example, you'll create a t-digest with a compression of 100 and add items to it. The <code> COMPRESSION </code> argument is used to specify the tradeoff between accuracy and memory consumption. The default value is 100. Higher values mean more accuracy. Note: unlike some of the other probabilistic data structures, the <a href="/docs/latest/commands/tdigest.add/"> <code> TDIGEST.ADD </code> </a> command will not create a new structure if the key does not exist. </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="tdigest_tutorial-steptdig_start"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_tdigest_tutorial-steptdig_start" name="tdigest_tutorial-steptdig_start" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_tdigest_tutorial-steptdig_start" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_start" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_tdigest_tutorial-steptdig_start" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; TDIGEST.CREATE bikes:sales COMPRESSION 100 </span></span><span class="line hl"><span class="cl">OK </span></span><span class="line hl"><span class="cl">&gt; TDIGEST.ADD bikes:sales 21 </span></span><span class="line hl"><span class="cl">OK </span></span><span class="line hl"><span class="cl">&gt; TDIGEST.ADD bikes:sales 150 95 75 34 </span></span><span class="line hl"><span class="cl">OK</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_tdigest_tutorial-steptdig_start')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_tdigest_tutorial-steptdig_start" name="tdigest_tutorial-steptdig_start" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_tdigest_tutorial-steptdig_start" title="Open example"> Python </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_start" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_tdigest_tutorial-steptdig_start" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for t-digest pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/probabilistic/t-digest/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="s2">"bikes:sales"</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s2">"bikes:sales"</span><span class="p">,</span> <span class="p">[</span><span class="mi">21</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; OK</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s2">"bikes:sales"</span><span class="p">,</span> <span class="p">[</span><span class="mi">150</span><span class="p">,</span> <span class="mi">95</span><span class="p">,</span> <span class="mi">75</span><span class="p">,</span> <span class="mi">34</span><span class="p">])</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; OK</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">add</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"racer_ages"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="mf">45.88</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">44.2</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">58.03</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">19.76</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">39.84</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">69.28</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">50.97</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">25.41</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">19.27</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">85.71</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">42.63</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; OK</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">rank</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">,</span> <span class="mi">50</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [7]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">rank</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="mi">40</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [7, 4]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">quantile</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [44.2]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">byrank</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">,</span> <span class="mi">4</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [42.63]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">min</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 19.27</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">max</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 85.71</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">reset</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; OK</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_tdigest_tutorial-steptdig_start')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_tdigest_tutorial-steptdig_start" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_tdigest.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_tdigest_tutorial-steptdig_start" name="tdigest_tutorial-steptdig_start" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_tdigest_tutorial-steptdig_start" title="Open example"> Node.js </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_start" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_tdigest_tutorial-steptdig_start" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">create</span><span class="p">(</span><span class="s1">'bikes:sales'</span><span class="p">,</span> <span class="mi">100</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s1">'bikes:sales'</span><span class="p">,</span> <span class="p">[</span><span class="mi">21</span><span class="p">]);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s1">'bikes:sales'</span><span class="p">,</span> <span class="p">[</span><span class="mi">150</span><span class="p">,</span> <span class="mi">95</span><span class="p">,</span> <span class="mi">75</span><span class="p">,</span> <span class="mi">34</span><span class="p">]);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">create</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">,</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="mf">45.88</span><span class="p">,</span> <span class="mf">44.2</span><span class="p">,</span> <span class="mf">58.03</span><span class="p">,</span> <span class="mf">19.76</span><span class="p">,</span> <span class="mf">39.84</span><span class="p">,</span> <span class="mf">69.28</span><span class="p">,</span> <span class="mf">50.97</span><span class="p">,</span> <span class="mf">25.41</span><span class="p">,</span> <span class="mf">19.27</span><span class="p">,</span> <span class="mf">85.71</span><span class="p">,</span> <span class="mf">42.63</span> </span></span><span class="line"><span class="cl"><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">rank</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">,</span> <span class="p">[</span><span class="mi">50</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [7] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">rank</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">,</span> <span class="p">[</span><span class="mi">50</span><span class="p">,</span> <span class="mi">40</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [7, 4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">quantile</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">,</span> <span class="p">[</span><span class="mf">0.5</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [44.2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">byRank</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">,</span> <span class="p">[</span><span class="mi">4</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [42.63] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">min</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 19.27 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">max</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 85.71 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">reset</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_tdigest_tutorial-steptdig_start')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_tdigest_tutorial-steptdig_start" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-tdigest.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_tdigest_tutorial-steptdig_start" name="tdigest_tutorial-steptdig_start" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_tdigest_tutorial-steptdig_start" title="Open example"> Java </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_start" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_tdigest_tutorial-steptdig_start" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">TDigestExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">(){</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">unifiedJedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://127.0.0.1:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestCreate</span><span class="o">(</span><span class="s">"bikes:sales"</span><span class="o">,</span> <span class="mi">100</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; True </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestAdd</span><span class="o">(</span><span class="s">"bikes:sales"</span><span class="o">,</span> <span class="mi">21</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestAdd</span><span class="o">(</span><span class="s">"bikes:sales"</span><span class="o">,</span> <span class="mi">150</span><span class="o">,</span> <span class="mi">95</span><span class="o">,</span> <span class="mi">75</span><span class="o">,</span> <span class="mi">34</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestCreate</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; True </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestAdd</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">,</span> <span class="mf">45.88</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">44.2</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">58.03</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">19.76</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">39.84</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">69.28</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">50.97</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">25.41</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">19.27</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">85.71</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">42.63</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestRank</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">,</span> <span class="mi">50</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [7] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestRank</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">,</span> <span class="mi">50</span><span class="o">,</span> <span class="mi">40</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [7, 4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Double</span><span class="o">&gt;</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestQuantile</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">,</span> <span class="mf">0.5</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [44.2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Double</span><span class="o">&gt;</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestByRank</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">,</span> <span class="mi">4</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [42.63] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestMin</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 19.27 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestMax</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 85.71 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestReset</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_tdigest_tutorial-steptdig_start')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_tdigest_tutorial-steptdig_start" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/TDigestExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_tdigest_tutorial-steptdig_start" name="tdigest_tutorial-steptdig_start" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_tdigest_tutorial-steptdig_start" title="Open example"> Go </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_start" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_tdigest_tutorial-steptdig_start" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_tdigstart</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestCreate</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:sales"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:sales"</span><span class="p">,</span> <span class="mi">21</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:sales"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="mi">150</span><span class="p">,</span> <span class="mi">95</span><span class="p">,</span> <span class="mi">75</span><span class="p">,</span> <span class="mi">34</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_tdigcdf</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestCreate</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">45.88</span><span class="p">,</span> <span class="mf">44.2</span><span class="p">,</span> <span class="mf">58.03</span><span class="p">,</span> <span class="mf">19.76</span><span class="p">,</span> <span class="mf">39.84</span><span class="p">,</span> <span class="mf">69.28</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">50.97</span><span class="p">,</span> <span class="mf">25.41</span><span class="p">,</span> <span class="mf">19.27</span><span class="p">,</span> <span class="mf">85.71</span><span class="p">,</span> <span class="mf">42.63</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> <span class="mi">50</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [7] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="mi">40</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [7 4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_tdigquant</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestCreate</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">45.88</span><span class="p">,</span> <span class="mf">44.2</span><span class="p">,</span> <span class="mf">58.03</span><span class="p">,</span> <span class="mf">19.76</span><span class="p">,</span> <span class="mf">39.84</span><span class="p">,</span> <span class="mf">69.28</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">50.97</span><span class="p">,</span> <span class="mf">25.41</span><span class="p">,</span> <span class="mf">19.27</span><span class="p">,</span> <span class="mf">85.71</span><span class="p">,</span> <span class="mf">42.63</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestQuantile</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [44.2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestByRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> <span class="mi">4</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [42.63] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_tdigmin</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestCreate</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">45.88</span><span class="p">,</span> <span class="mf">44.2</span><span class="p">,</span> <span class="mf">58.03</span><span class="p">,</span> <span class="mf">19.76</span><span class="p">,</span> <span class="mf">39.84</span><span class="p">,</span> <span class="mf">69.28</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">50.97</span><span class="p">,</span> <span class="mf">25.41</span><span class="p">,</span> <span class="mf">19.27</span><span class="p">,</span> <span class="mf">85.71</span><span class="p">,</span> <span class="mf">42.63</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestMin</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 19.27 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestMax</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 85.71 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_tdigreset</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestCreate</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestReset</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_tdigest_tutorial-steptdig_start')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_tdigest_tutorial-steptdig_start" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/tdigest_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_tdigest_tutorial-steptdig_start" name="tdigest_tutorial-steptdig_start" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_tdigest_tutorial-steptdig_start" title="Open example"> C# </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_start" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_tdigest_tutorial-steptdig_start" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.RedisStackCommands</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">Tdigest_tutorial</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">bool</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Create</span><span class="p">(</span><span class="s">"bikes:sales"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">bool</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Add</span><span class="p">(</span><span class="s">"bikes:sales"</span><span class="p">,</span> <span class="m">21</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">bool</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Add</span><span class="p">(</span><span class="s">"bikes:sales"</span><span class="p">,</span> <span class="m">150</span><span class="p">,</span> <span class="m">95</span><span class="p">,</span> <span class="m">75</span><span class="p">,</span> <span class="m">34</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'tdig_start' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Create</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Add</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">45.88</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">44.2</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">58.03</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">19.76</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">39.84</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">69.28</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">50.97</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">25.41</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">19.27</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">85.71</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">42.63</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span><span class="p">[]</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Rank</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">,</span> <span class="m">50</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res6</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 7</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span><span class="p">[]</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Rank</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">,</span> <span class="m">50</span><span class="p">,</span> <span class="m">40</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res7</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 7, 4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'tdig_cdf' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double</span><span class="p">[]</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Quantile</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">,</span> <span class="m">0.5</span><span class="p">);</span> <span class="p">;</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res8</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 44.2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double</span><span class="p">[]</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">ByRank</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">,</span> <span class="m">4</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res9</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 42.63</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'tdig_quant' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Min</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res10</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 19.27</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Max</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 85.71</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'tdig_min' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Reset</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'tdig_reset' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_tdigest_tutorial-steptdig_start')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_tdigest_tutorial-steptdig_start" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/Tdigest_tutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> You can repeat calling <a href="/docs/latest/commands/tdigest.add"> TDIGEST.ADD </a> whenever new observations are available </p> <h4 id="estimating-fractions-or-ranks-by-values"> Estimating fractions or ranks by values </h4> <p> Another helpful feature in t-digest is CDF (definition of rank) which gives us the fraction of observations smaller or equal to a certain value. This command is very useful to answer questions like " <em> What's the percentage of observations with a value lower or equal to X </em> ". </p> <blockquote> <p> More precisely, <a href="/docs/latest/commands/tdigest.cdf/"> <code> TDIGEST.CDF </code> </a> will return the estimated fraction of observations in the sketch that are smaller than X plus half the number of observations that are equal to X. We can also use the <a href="/docs/latest/commands/tdigest.rank/"> <code> TDIGEST.RANK </code> </a> command, which is very similar. Instead of returning a fraction, it returns the ----estimated---- rank of a value. The <a href="/docs/latest/commands/tdigest.rank/"> <code> TDIGEST.RANK </code> </a> command is also variadic, meaning you can use a single command to retrieve estimations for one or more values. </p> </blockquote> <p> Here's an example. Given a set of biker's ages, you can ask a question like "What's the percentage of bike racers that are younger than 50 years?" </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="tdigest_tutorial-steptdig_cdf"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_tdigest_tutorial-steptdig_cdf" name="tdigest_tutorial-steptdig_cdf" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_tdigest_tutorial-steptdig_cdf" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_cdf" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_tdigest_tutorial-steptdig_cdf" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; TDIGEST.CREATE racer_ages </span></span><span class="line hl"><span class="cl">OK </span></span><span class="line hl"><span class="cl">&gt; TDIGEST.ADD racer_ages 45.88 44.2 58.03 19.76 39.84 69.28 50.97 25.41 19.27 85.71 42.63 </span></span><span class="line hl"><span class="cl">OK </span></span><span class="line hl"><span class="cl">&gt; TDIGEST.CDF racer_ages 50 </span></span><span class="line hl"><span class="cl">1) "0.63636363636363635" </span></span><span class="line hl"><span class="cl">&gt; TDIGEST.RANK racer_ages 50 </span></span><span class="line hl"><span class="cl">1) (integer) 7 </span></span><span class="line hl"><span class="cl">&gt; TDIGEST.RANK racer_ages 50 40 </span></span><span class="line hl"><span class="cl">1) (integer) 7 </span></span><span class="line hl"><span class="cl">2) (integer) 4</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_tdigest_tutorial-steptdig_cdf')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_tdigest_tutorial-steptdig_cdf" name="tdigest_tutorial-steptdig_cdf" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_tdigest_tutorial-steptdig_cdf" title="Open example"> Python </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_cdf" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_tdigest_tutorial-steptdig_cdf" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for t-digest pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/probabilistic/t-digest/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="s2">"bikes:sales"</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s2">"bikes:sales"</span><span class="p">,</span> <span class="p">[</span><span class="mi">21</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; OK</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s2">"bikes:sales"</span><span class="p">,</span> <span class="p">[</span><span class="mi">150</span><span class="p">,</span> <span class="mi">95</span><span class="p">,</span> <span class="mi">75</span><span class="p">,</span> <span class="mi">34</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; OK</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">add</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"racer_ages"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="p">[</span> </span></span><span class="line hl"><span class="cl"> <span class="mf">45.88</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="mf">44.2</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="mf">58.03</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="mf">19.76</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="mf">39.84</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="mf">69.28</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="mf">50.97</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="mf">25.41</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="mf">19.27</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="mf">85.71</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="mf">42.63</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="p">],</span> </span></span><span class="line hl"><span class="cl"><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; OK</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">rank</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">,</span> <span class="mi">50</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [7]</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">rank</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="mi">40</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [7, 4]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">quantile</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [44.2]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">byrank</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">,</span> <span class="mi">4</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [42.63]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">min</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 19.27</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">max</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 85.71</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">reset</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; OK</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_tdigest_tutorial-steptdig_cdf')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_tdigest_tutorial-steptdig_cdf" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_tdigest.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_tdigest_tutorial-steptdig_cdf" name="tdigest_tutorial-steptdig_cdf" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_tdigest_tutorial-steptdig_cdf" title="Open example"> Node.js </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_cdf" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_tdigest_tutorial-steptdig_cdf" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">create</span><span class="p">(</span><span class="s1">'bikes:sales'</span><span class="p">,</span> <span class="mi">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s1">'bikes:sales'</span><span class="p">,</span> <span class="p">[</span><span class="mi">21</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s1">'bikes:sales'</span><span class="p">,</span> <span class="p">[</span><span class="mi">150</span><span class="p">,</span> <span class="mi">95</span><span class="p">,</span> <span class="mi">75</span><span class="p">,</span> <span class="mi">34</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">create</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">,</span> <span class="p">[</span> </span></span><span class="line hl"><span class="cl"> <span class="mf">45.88</span><span class="p">,</span> <span class="mf">44.2</span><span class="p">,</span> <span class="mf">58.03</span><span class="p">,</span> <span class="mf">19.76</span><span class="p">,</span> <span class="mf">39.84</span><span class="p">,</span> <span class="mf">69.28</span><span class="p">,</span> <span class="mf">50.97</span><span class="p">,</span> <span class="mf">25.41</span><span class="p">,</span> <span class="mf">19.27</span><span class="p">,</span> <span class="mf">85.71</span><span class="p">,</span> <span class="mf">42.63</span> </span></span><span class="line hl"><span class="cl"><span class="p">]);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">rank</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">,</span> <span class="p">[</span><span class="mi">50</span><span class="p">]);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [7] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">rank</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">,</span> <span class="p">[</span><span class="mi">50</span><span class="p">,</span> <span class="mi">40</span><span class="p">]);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [7, 4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">quantile</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">,</span> <span class="p">[</span><span class="mf">0.5</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [44.2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">byRank</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">,</span> <span class="p">[</span><span class="mi">4</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [42.63] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">min</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 19.27 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">max</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 85.71 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">reset</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_tdigest_tutorial-steptdig_cdf')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_tdigest_tutorial-steptdig_cdf" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-tdigest.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_tdigest_tutorial-steptdig_cdf" name="tdigest_tutorial-steptdig_cdf" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_tdigest_tutorial-steptdig_cdf" title="Open example"> Java </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_cdf" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_tdigest_tutorial-steptdig_cdf" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">TDigestExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">(){</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">unifiedJedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://127.0.0.1:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestCreate</span><span class="o">(</span><span class="s">"bikes:sales"</span><span class="o">,</span> <span class="mi">100</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; True </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestAdd</span><span class="o">(</span><span class="s">"bikes:sales"</span><span class="o">,</span> <span class="mi">21</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestAdd</span><span class="o">(</span><span class="s">"bikes:sales"</span><span class="o">,</span> <span class="mi">150</span><span class="o">,</span> <span class="mi">95</span><span class="o">,</span> <span class="mi">75</span><span class="o">,</span> <span class="mi">34</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestCreate</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; True </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestAdd</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">,</span> <span class="mf">45.88</span><span class="o">,</span> </span></span><span class="line hl"><span class="cl"> <span class="mf">44.2</span><span class="o">,</span> </span></span><span class="line hl"><span class="cl"> <span class="mf">58.03</span><span class="o">,</span> </span></span><span class="line hl"><span class="cl"> <span class="mf">19.76</span><span class="o">,</span> </span></span><span class="line hl"><span class="cl"> <span class="mf">39.84</span><span class="o">,</span> </span></span><span class="line hl"><span class="cl"> <span class="mf">69.28</span><span class="o">,</span> </span></span><span class="line hl"><span class="cl"> <span class="mf">50.97</span><span class="o">,</span> </span></span><span class="line hl"><span class="cl"> <span class="mf">25.41</span><span class="o">,</span> </span></span><span class="line hl"><span class="cl"> <span class="mf">19.27</span><span class="o">,</span> </span></span><span class="line hl"><span class="cl"> <span class="mf">85.71</span><span class="o">,</span> </span></span><span class="line hl"><span class="cl"> <span class="mf">42.63</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestRank</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">,</span> <span class="mi">50</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [7] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestRank</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">,</span> <span class="mi">50</span><span class="o">,</span> <span class="mi">40</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [7, 4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Double</span><span class="o">&gt;</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestQuantile</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">,</span> <span class="mf">0.5</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [44.2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Double</span><span class="o">&gt;</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestByRank</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">,</span> <span class="mi">4</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [42.63] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestMin</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 19.27 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestMax</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 85.71 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestReset</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_tdigest_tutorial-steptdig_cdf')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_tdigest_tutorial-steptdig_cdf" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/TDigestExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_tdigest_tutorial-steptdig_cdf" name="tdigest_tutorial-steptdig_cdf" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_tdigest_tutorial-steptdig_cdf" title="Open example"> Go </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_cdf" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_tdigest_tutorial-steptdig_cdf" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_tdigstart</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestCreate</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:sales"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:sales"</span><span class="p">,</span> <span class="mi">21</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:sales"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mi">150</span><span class="p">,</span> <span class="mi">95</span><span class="p">,</span> <span class="mi">75</span><span class="p">,</span> <span class="mi">34</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_tdigcdf</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestCreate</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="mf">45.88</span><span class="p">,</span> <span class="mf">44.2</span><span class="p">,</span> <span class="mf">58.03</span><span class="p">,</span> <span class="mf">19.76</span><span class="p">,</span> <span class="mf">39.84</span><span class="p">,</span> <span class="mf">69.28</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="mf">50.97</span><span class="p">,</span> <span class="mf">25.41</span><span class="p">,</span> <span class="mf">19.27</span><span class="p">,</span> <span class="mf">85.71</span><span class="p">,</span> <span class="mf">42.63</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> <span class="mi">50</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [7] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="mi">40</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [7 4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_tdigquant</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestCreate</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">45.88</span><span class="p">,</span> <span class="mf">44.2</span><span class="p">,</span> <span class="mf">58.03</span><span class="p">,</span> <span class="mf">19.76</span><span class="p">,</span> <span class="mf">39.84</span><span class="p">,</span> <span class="mf">69.28</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">50.97</span><span class="p">,</span> <span class="mf">25.41</span><span class="p">,</span> <span class="mf">19.27</span><span class="p">,</span> <span class="mf">85.71</span><span class="p">,</span> <span class="mf">42.63</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestQuantile</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [44.2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestByRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> <span class="mi">4</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [42.63] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_tdigmin</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestCreate</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">45.88</span><span class="p">,</span> <span class="mf">44.2</span><span class="p">,</span> <span class="mf">58.03</span><span class="p">,</span> <span class="mf">19.76</span><span class="p">,</span> <span class="mf">39.84</span><span class="p">,</span> <span class="mf">69.28</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">50.97</span><span class="p">,</span> <span class="mf">25.41</span><span class="p">,</span> <span class="mf">19.27</span><span class="p">,</span> <span class="mf">85.71</span><span class="p">,</span> <span class="mf">42.63</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestMin</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 19.27 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestMax</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 85.71 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_tdigreset</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestCreate</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestReset</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_tdigest_tutorial-steptdig_cdf')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_tdigest_tutorial-steptdig_cdf" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/tdigest_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_tdigest_tutorial-steptdig_cdf" name="tdigest_tutorial-steptdig_cdf" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_tdigest_tutorial-steptdig_cdf" title="Open example"> C# </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_cdf" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_tdigest_tutorial-steptdig_cdf" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.RedisStackCommands</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">Tdigest_tutorial</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Create</span><span class="p">(</span><span class="s">"bikes:sales"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Add</span><span class="p">(</span><span class="s">"bikes:sales"</span><span class="p">,</span> <span class="m">21</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Add</span><span class="p">(</span><span class="s">"bikes:sales"</span><span class="p">,</span> <span class="m">150</span><span class="p">,</span> <span class="m">95</span><span class="p">,</span> <span class="m">75</span><span class="p">,</span> <span class="m">34</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'tdig_start' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">bool</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Create</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">bool</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Add</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="m">45.88</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="m">44.2</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="m">58.03</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="m">19.76</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="m">39.84</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="m">69.28</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="m">50.97</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="m">25.41</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="m">19.27</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="m">85.71</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="m">42.63</span> </span></span><span class="line hl"><span class="cl"> <span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span><span class="p">[]</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Rank</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">,</span> <span class="m">50</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res6</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 7</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long</span><span class="p">[]</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Rank</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">,</span> <span class="m">50</span><span class="p">,</span> <span class="m">40</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res7</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 7, 4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'tdig_cdf' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double</span><span class="p">[]</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Quantile</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">,</span> <span class="m">0.5</span><span class="p">);</span> <span class="p">;</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res8</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 44.2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double</span><span class="p">[]</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">ByRank</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">,</span> <span class="m">4</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res9</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 42.63</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'tdig_quant' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Min</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res10</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 19.27</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Max</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 85.71</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'tdig_min' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Reset</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'tdig_reset' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_tdigest_tutorial-steptdig_cdf')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_tdigest_tutorial-steptdig_cdf" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/Tdigest_tutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> And lastly, <code> TDIGEST.REVRANK key value... </code> is similar to <a href="/docs/latest/commands/tdigest.rank"> TDIGEST.RANK </a> , but returns, for each input value, an estimation of the number of (observations larger than a given value + half the observations equal to the given value). </p> <h4 id="estimating-values-by-fractions-or-ranks"> Estimating values by fractions or ranks </h4> <p> <code> TDIGEST.QUANTILE key fraction... </code> returns, for each input fraction, an estimation of the value (floating point) that is smaller than the given fraction of observations. <code> TDIGEST.BYRANK key rank... </code> returns, for each input rank, an estimation of the value (floating point) with that rank. </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="tdigest_tutorial-steptdig_quant"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_tdigest_tutorial-steptdig_quant" name="tdigest_tutorial-steptdig_quant" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_tdigest_tutorial-steptdig_quant" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_quant" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_tdigest_tutorial-steptdig_quant" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; TDIGEST.QUANTILE racer_ages .5 </span></span><span class="line hl"><span class="cl">1) "44.200000000000003" </span></span><span class="line hl"><span class="cl">&gt; TDIGEST.BYRANK racer_ages 4 </span></span><span class="line hl"><span class="cl">1) "42.630000000000003"</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_tdigest_tutorial-steptdig_quant')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_tdigest_tutorial-steptdig_quant" name="tdigest_tutorial-steptdig_quant" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_tdigest_tutorial-steptdig_quant" title="Open example"> Python </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_quant" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_tdigest_tutorial-steptdig_quant" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for t-digest pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/probabilistic/t-digest/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="s2">"bikes:sales"</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s2">"bikes:sales"</span><span class="p">,</span> <span class="p">[</span><span class="mi">21</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; OK</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s2">"bikes:sales"</span><span class="p">,</span> <span class="p">[</span><span class="mi">150</span><span class="p">,</span> <span class="mi">95</span><span class="p">,</span> <span class="mi">75</span><span class="p">,</span> <span class="mi">34</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; OK</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">add</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"racer_ages"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="mf">45.88</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">44.2</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">58.03</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">19.76</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">39.84</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">69.28</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">50.97</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">25.41</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">19.27</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">85.71</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">42.63</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; OK</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">rank</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">,</span> <span class="mi">50</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [7]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">rank</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="mi">40</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [7, 4]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">quantile</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [44.2]</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">byrank</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">,</span> <span class="mi">4</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [42.63]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">min</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 19.27</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">max</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 85.71</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">reset</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; OK</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_tdigest_tutorial-steptdig_quant')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_tdigest_tutorial-steptdig_quant" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_tdigest.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_tdigest_tutorial-steptdig_quant" name="tdigest_tutorial-steptdig_quant" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_tdigest_tutorial-steptdig_quant" title="Open example"> Node.js </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_quant" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_tdigest_tutorial-steptdig_quant" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">create</span><span class="p">(</span><span class="s1">'bikes:sales'</span><span class="p">,</span> <span class="mi">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s1">'bikes:sales'</span><span class="p">,</span> <span class="p">[</span><span class="mi">21</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s1">'bikes:sales'</span><span class="p">,</span> <span class="p">[</span><span class="mi">150</span><span class="p">,</span> <span class="mi">95</span><span class="p">,</span> <span class="mi">75</span><span class="p">,</span> <span class="mi">34</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">create</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">,</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="mf">45.88</span><span class="p">,</span> <span class="mf">44.2</span><span class="p">,</span> <span class="mf">58.03</span><span class="p">,</span> <span class="mf">19.76</span><span class="p">,</span> <span class="mf">39.84</span><span class="p">,</span> <span class="mf">69.28</span><span class="p">,</span> <span class="mf">50.97</span><span class="p">,</span> <span class="mf">25.41</span><span class="p">,</span> <span class="mf">19.27</span><span class="p">,</span> <span class="mf">85.71</span><span class="p">,</span> <span class="mf">42.63</span> </span></span><span class="line"><span class="cl"><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">rank</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">,</span> <span class="p">[</span><span class="mi">50</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [7] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">rank</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">,</span> <span class="p">[</span><span class="mi">50</span><span class="p">,</span> <span class="mi">40</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [7, 4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">quantile</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">,</span> <span class="p">[</span><span class="mf">0.5</span><span class="p">]);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [44.2] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">byRank</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">,</span> <span class="p">[</span><span class="mi">4</span><span class="p">]);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [42.63] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">min</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 19.27 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">max</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 85.71 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">reset</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_tdigest_tutorial-steptdig_quant')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_tdigest_tutorial-steptdig_quant" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-tdigest.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_tdigest_tutorial-steptdig_quant" name="tdigest_tutorial-steptdig_quant" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_tdigest_tutorial-steptdig_quant" title="Open example"> Java </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_quant" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_tdigest_tutorial-steptdig_quant" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">TDigestExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">(){</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">unifiedJedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://127.0.0.1:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestCreate</span><span class="o">(</span><span class="s">"bikes:sales"</span><span class="o">,</span> <span class="mi">100</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; True </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestAdd</span><span class="o">(</span><span class="s">"bikes:sales"</span><span class="o">,</span> <span class="mi">21</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestAdd</span><span class="o">(</span><span class="s">"bikes:sales"</span><span class="o">,</span> <span class="mi">150</span><span class="o">,</span> <span class="mi">95</span><span class="o">,</span> <span class="mi">75</span><span class="o">,</span> <span class="mi">34</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestCreate</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; True </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestAdd</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">,</span> <span class="mf">45.88</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">44.2</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">58.03</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">19.76</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">39.84</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">69.28</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">50.97</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">25.41</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">19.27</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">85.71</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">42.63</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestRank</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">,</span> <span class="mi">50</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [7] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestRank</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">,</span> <span class="mi">50</span><span class="o">,</span> <span class="mi">40</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [7, 4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Double</span><span class="o">&gt;</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestQuantile</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">,</span> <span class="mf">0.5</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [44.2] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Double</span><span class="o">&gt;</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestByRank</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">,</span> <span class="mi">4</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [42.63] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestMin</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 19.27 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestMax</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 85.71 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestReset</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_tdigest_tutorial-steptdig_quant')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_tdigest_tutorial-steptdig_quant" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/TDigestExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_tdigest_tutorial-steptdig_quant" name="tdigest_tutorial-steptdig_quant" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_tdigest_tutorial-steptdig_quant" title="Open example"> Go </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_quant" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_tdigest_tutorial-steptdig_quant" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_tdigstart</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestCreate</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:sales"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:sales"</span><span class="p">,</span> <span class="mi">21</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:sales"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mi">150</span><span class="p">,</span> <span class="mi">95</span><span class="p">,</span> <span class="mi">75</span><span class="p">,</span> <span class="mi">34</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_tdigcdf</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestCreate</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">45.88</span><span class="p">,</span> <span class="mf">44.2</span><span class="p">,</span> <span class="mf">58.03</span><span class="p">,</span> <span class="mf">19.76</span><span class="p">,</span> <span class="mf">39.84</span><span class="p">,</span> <span class="mf">69.28</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">50.97</span><span class="p">,</span> <span class="mf">25.41</span><span class="p">,</span> <span class="mf">19.27</span><span class="p">,</span> <span class="mf">85.71</span><span class="p">,</span> <span class="mf">42.63</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> <span class="mi">50</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [7] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="mi">40</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [7 4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_tdigquant</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestCreate</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">45.88</span><span class="p">,</span> <span class="mf">44.2</span><span class="p">,</span> <span class="mf">58.03</span><span class="p">,</span> <span class="mf">19.76</span><span class="p">,</span> <span class="mf">39.84</span><span class="p">,</span> <span class="mf">69.28</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">50.97</span><span class="p">,</span> <span class="mf">25.41</span><span class="p">,</span> <span class="mf">19.27</span><span class="p">,</span> <span class="mf">85.71</span><span class="p">,</span> <span class="mf">42.63</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestQuantile</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [44.2] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestByRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> <span class="mi">4</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [42.63] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_tdigmin</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestCreate</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">45.88</span><span class="p">,</span> <span class="mf">44.2</span><span class="p">,</span> <span class="mf">58.03</span><span class="p">,</span> <span class="mf">19.76</span><span class="p">,</span> <span class="mf">39.84</span><span class="p">,</span> <span class="mf">69.28</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">50.97</span><span class="p">,</span> <span class="mf">25.41</span><span class="p">,</span> <span class="mf">19.27</span><span class="p">,</span> <span class="mf">85.71</span><span class="p">,</span> <span class="mf">42.63</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestMin</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 19.27 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestMax</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 85.71 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_tdigreset</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestCreate</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestReset</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_tdigest_tutorial-steptdig_quant')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_tdigest_tutorial-steptdig_quant" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/tdigest_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_tdigest_tutorial-steptdig_quant" name="tdigest_tutorial-steptdig_quant" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_tdigest_tutorial-steptdig_quant" title="Open example"> C# </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_quant" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_tdigest_tutorial-steptdig_quant" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.RedisStackCommands</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">Tdigest_tutorial</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Create</span><span class="p">(</span><span class="s">"bikes:sales"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Add</span><span class="p">(</span><span class="s">"bikes:sales"</span><span class="p">,</span> <span class="m">21</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Add</span><span class="p">(</span><span class="s">"bikes:sales"</span><span class="p">,</span> <span class="m">150</span><span class="p">,</span> <span class="m">95</span><span class="p">,</span> <span class="m">75</span><span class="p">,</span> <span class="m">34</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'tdig_start' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Create</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Add</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">45.88</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">44.2</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">58.03</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">19.76</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">39.84</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">69.28</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">50.97</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">25.41</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">19.27</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">85.71</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">42.63</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span><span class="p">[]</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Rank</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">,</span> <span class="m">50</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res6</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 7</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span><span class="p">[]</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Rank</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">,</span> <span class="m">50</span><span class="p">,</span> <span class="m">40</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res7</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 7, 4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'tdig_cdf' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">double</span><span class="p">[]</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Quantile</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">,</span> <span class="m">0.5</span><span class="p">);</span> <span class="p">;</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res8</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 44.2</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">double</span><span class="p">[]</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">ByRank</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">,</span> <span class="m">4</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res9</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 42.63</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'tdig_quant' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Min</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res10</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 19.27</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Max</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 85.71</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'tdig_min' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Reset</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'tdig_reset' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_tdigest_tutorial-steptdig_quant')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_tdigest_tutorial-steptdig_quant" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/Tdigest_tutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> <code> TDIGEST.BYREVRANK key rank... </code> returns, for each input <strong> reverse rank </strong> , an estimation of the <strong> value </strong> (floating point) with that reverse rank. </p> <h4 id="estimating-trimmed-mean"> Estimating trimmed mean </h4> <p> Use <code> TDIGEST.TRIMMED_MEAN key lowFraction highFraction </code> to retrieve an estimation of the mean value between the specified fractions. </p> <p> This is especially useful for calculating the average value ignoring outliers. For example - calculating the average value between the 20th percentile and the 80th percentile. </p> <h4 id="merging-sketches"> Merging sketches </h4> <p> Sometimes it is useful to merge sketches. For example, suppose we measure latencies for 3 servers, and we want to calculate the 90%, 95%, and 99% latencies for all the servers combined. </p> <p> <code> TDIGEST.MERGE destKey numKeys sourceKey... [COMPRESSION compression] [OVERRIDE] </code> merges multiple sketches into a single sketch. </p> <p> If <code> destKey </code> does not exist - a new sketch is created. </p> <p> If <code> destKey </code> is an existing sketch, its values are merged with the values of the source keys. To override the destination key contents, use <code> OVERRIDE </code> . </p> <h4 id="retrieving-sketch-information"> Retrieving sketch information </h4> <p> Use <a href="/docs/latest/commands/tdigest.min/"> <code> TDIGEST.MIN </code> </a> and <a href="/docs/latest/commands/tdigest.max/"> <code> TDIGEST.MAX </code> </a> to retrieve the minimal and maximal values in the sketch, respectively. </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="tdigest_tutorial-steptdig_min"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_tdigest_tutorial-steptdig_min" name="tdigest_tutorial-steptdig_min" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_tdigest_tutorial-steptdig_min" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_min" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_tdigest_tutorial-steptdig_min" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; TDIGEST.MIN racer_ages </span></span><span class="line hl"><span class="cl">"19.27" </span></span><span class="line hl"><span class="cl">&gt; TDIGEST.MAX racer_ages </span></span><span class="line hl"><span class="cl">"85.709999999999994"</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_tdigest_tutorial-steptdig_min')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_tdigest_tutorial-steptdig_min" name="tdigest_tutorial-steptdig_min" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_tdigest_tutorial-steptdig_min" title="Open example"> Python </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_min" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_tdigest_tutorial-steptdig_min" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for t-digest pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/probabilistic/t-digest/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="s2">"bikes:sales"</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s2">"bikes:sales"</span><span class="p">,</span> <span class="p">[</span><span class="mi">21</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; OK</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s2">"bikes:sales"</span><span class="p">,</span> <span class="p">[</span><span class="mi">150</span><span class="p">,</span> <span class="mi">95</span><span class="p">,</span> <span class="mi">75</span><span class="p">,</span> <span class="mi">34</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; OK</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">add</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"racer_ages"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="mf">45.88</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">44.2</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">58.03</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">19.76</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">39.84</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">69.28</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">50.97</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">25.41</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">19.27</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">85.71</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">42.63</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; OK</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">rank</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">,</span> <span class="mi">50</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [7]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">rank</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="mi">40</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [7, 4]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">quantile</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [44.2]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">byrank</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">,</span> <span class="mi">4</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [42.63]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">min</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 19.27</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">max</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 85.71</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">reset</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; OK</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_tdigest_tutorial-steptdig_min')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_tdigest_tutorial-steptdig_min" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_tdigest.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_tdigest_tutorial-steptdig_min" name="tdigest_tutorial-steptdig_min" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_tdigest_tutorial-steptdig_min" title="Open example"> Node.js </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_min" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_tdigest_tutorial-steptdig_min" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">create</span><span class="p">(</span><span class="s1">'bikes:sales'</span><span class="p">,</span> <span class="mi">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s1">'bikes:sales'</span><span class="p">,</span> <span class="p">[</span><span class="mi">21</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s1">'bikes:sales'</span><span class="p">,</span> <span class="p">[</span><span class="mi">150</span><span class="p">,</span> <span class="mi">95</span><span class="p">,</span> <span class="mi">75</span><span class="p">,</span> <span class="mi">34</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">create</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">,</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="mf">45.88</span><span class="p">,</span> <span class="mf">44.2</span><span class="p">,</span> <span class="mf">58.03</span><span class="p">,</span> <span class="mf">19.76</span><span class="p">,</span> <span class="mf">39.84</span><span class="p">,</span> <span class="mf">69.28</span><span class="p">,</span> <span class="mf">50.97</span><span class="p">,</span> <span class="mf">25.41</span><span class="p">,</span> <span class="mf">19.27</span><span class="p">,</span> <span class="mf">85.71</span><span class="p">,</span> <span class="mf">42.63</span> </span></span><span class="line"><span class="cl"><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">rank</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">,</span> <span class="p">[</span><span class="mi">50</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [7] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">rank</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">,</span> <span class="p">[</span><span class="mi">50</span><span class="p">,</span> <span class="mi">40</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [7, 4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">quantile</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">,</span> <span class="p">[</span><span class="mf">0.5</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [44.2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">byRank</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">,</span> <span class="p">[</span><span class="mi">4</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [42.63] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">min</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 19.27 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">max</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 85.71 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">reset</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_tdigest_tutorial-steptdig_min')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_tdigest_tutorial-steptdig_min" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-tdigest.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_tdigest_tutorial-steptdig_min" name="tdigest_tutorial-steptdig_min" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_tdigest_tutorial-steptdig_min" title="Open example"> Java </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_min" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_tdigest_tutorial-steptdig_min" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">TDigestExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">(){</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">unifiedJedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://127.0.0.1:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestCreate</span><span class="o">(</span><span class="s">"bikes:sales"</span><span class="o">,</span> <span class="mi">100</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; True </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestAdd</span><span class="o">(</span><span class="s">"bikes:sales"</span><span class="o">,</span> <span class="mi">21</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestAdd</span><span class="o">(</span><span class="s">"bikes:sales"</span><span class="o">,</span> <span class="mi">150</span><span class="o">,</span> <span class="mi">95</span><span class="o">,</span> <span class="mi">75</span><span class="o">,</span> <span class="mi">34</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestCreate</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; True </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestAdd</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">,</span> <span class="mf">45.88</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">44.2</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">58.03</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">19.76</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">39.84</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">69.28</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">50.97</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">25.41</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">19.27</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">85.71</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">42.63</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestRank</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">,</span> <span class="mi">50</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [7] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestRank</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">,</span> <span class="mi">50</span><span class="o">,</span> <span class="mi">40</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [7, 4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Double</span><span class="o">&gt;</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestQuantile</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">,</span> <span class="mf">0.5</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [44.2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Double</span><span class="o">&gt;</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestByRank</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">,</span> <span class="mi">4</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [42.63] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">double</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestMin</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 19.27 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="kt">double</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestMax</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 85.71 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestReset</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_tdigest_tutorial-steptdig_min')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_tdigest_tutorial-steptdig_min" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/TDigestExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_tdigest_tutorial-steptdig_min" name="tdigest_tutorial-steptdig_min" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_tdigest_tutorial-steptdig_min" title="Open example"> Go </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_min" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_tdigest_tutorial-steptdig_min" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_tdigstart</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestCreate</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:sales"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:sales"</span><span class="p">,</span> <span class="mi">21</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:sales"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mi">150</span><span class="p">,</span> <span class="mi">95</span><span class="p">,</span> <span class="mi">75</span><span class="p">,</span> <span class="mi">34</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_tdigcdf</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestCreate</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">45.88</span><span class="p">,</span> <span class="mf">44.2</span><span class="p">,</span> <span class="mf">58.03</span><span class="p">,</span> <span class="mf">19.76</span><span class="p">,</span> <span class="mf">39.84</span><span class="p">,</span> <span class="mf">69.28</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">50.97</span><span class="p">,</span> <span class="mf">25.41</span><span class="p">,</span> <span class="mf">19.27</span><span class="p">,</span> <span class="mf">85.71</span><span class="p">,</span> <span class="mf">42.63</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> <span class="mi">50</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [7] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="mi">40</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [7 4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_tdigquant</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestCreate</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">45.88</span><span class="p">,</span> <span class="mf">44.2</span><span class="p">,</span> <span class="mf">58.03</span><span class="p">,</span> <span class="mf">19.76</span><span class="p">,</span> <span class="mf">39.84</span><span class="p">,</span> <span class="mf">69.28</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">50.97</span><span class="p">,</span> <span class="mf">25.41</span><span class="p">,</span> <span class="mf">19.27</span><span class="p">,</span> <span class="mf">85.71</span><span class="p">,</span> <span class="mf">42.63</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestQuantile</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [44.2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestByRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> <span class="mi">4</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [42.63] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_tdigmin</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestCreate</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">45.88</span><span class="p">,</span> <span class="mf">44.2</span><span class="p">,</span> <span class="mf">58.03</span><span class="p">,</span> <span class="mf">19.76</span><span class="p">,</span> <span class="mf">39.84</span><span class="p">,</span> <span class="mf">69.28</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">50.97</span><span class="p">,</span> <span class="mf">25.41</span><span class="p">,</span> <span class="mf">19.27</span><span class="p">,</span> <span class="mf">85.71</span><span class="p">,</span> <span class="mf">42.63</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestMin</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 19.27 </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestMax</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 85.71 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_tdigreset</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestCreate</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestReset</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_tdigest_tutorial-steptdig_min')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_tdigest_tutorial-steptdig_min" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/tdigest_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_tdigest_tutorial-steptdig_min" name="tdigest_tutorial-steptdig_min" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_tdigest_tutorial-steptdig_min" title="Open example"> C# </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_min" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_tdigest_tutorial-steptdig_min" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.RedisStackCommands</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">Tdigest_tutorial</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Create</span><span class="p">(</span><span class="s">"bikes:sales"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Add</span><span class="p">(</span><span class="s">"bikes:sales"</span><span class="p">,</span> <span class="m">21</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Add</span><span class="p">(</span><span class="s">"bikes:sales"</span><span class="p">,</span> <span class="m">150</span><span class="p">,</span> <span class="m">95</span><span class="p">,</span> <span class="m">75</span><span class="p">,</span> <span class="m">34</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'tdig_start' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Create</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Add</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">45.88</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">44.2</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">58.03</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">19.76</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">39.84</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">69.28</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">50.97</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">25.41</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">19.27</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">85.71</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">42.63</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span><span class="p">[]</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Rank</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">,</span> <span class="m">50</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res6</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 7</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span><span class="p">[]</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Rank</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">,</span> <span class="m">50</span><span class="p">,</span> <span class="m">40</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res7</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 7, 4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'tdig_cdf' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double</span><span class="p">[]</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Quantile</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">,</span> <span class="m">0.5</span><span class="p">);</span> <span class="p">;</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res8</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 44.2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double</span><span class="p">[]</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">ByRank</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">,</span> <span class="m">4</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res9</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 42.63</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'tdig_quant' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">double</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Min</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res10</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 19.27</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">double</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Max</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 85.71</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'tdig_min' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Reset</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'tdig_reset' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_tdigest_tutorial-steptdig_min')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_tdigest_tutorial-steptdig_min" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/Tdigest_tutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> Both return <code> nan </code> when the sketch is empty. </p> <p> Both commands return accurate results and are equivalent to <code> TDIGEST.BYRANK racer_ages 0 </code> and <code> TDIGEST.BYREVRANK racer_ages 0 </code> , respectively. </p> <p> Use <code> TDIGEST.INFO racer_ages </code> to retrieve some additional information about the sketch. </p> <h4 id="resetting-a-sketch"> Resetting a sketch </h4> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="tdigest_tutorial-steptdig_reset"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_tdigest_tutorial-steptdig_reset" name="tdigest_tutorial-steptdig_reset" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_tdigest_tutorial-steptdig_reset" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_reset" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_tdigest_tutorial-steptdig_reset" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; TDIGEST.RESET racer_ages </span></span><span class="line hl"><span class="cl">OK</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_tdigest_tutorial-steptdig_reset')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_tdigest_tutorial-steptdig_reset" name="tdigest_tutorial-steptdig_reset" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_tdigest_tutorial-steptdig_reset" title="Open example"> Python </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_reset" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_tdigest_tutorial-steptdig_reset" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for t-digest pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/probabilistic/t-digest/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="s2">"bikes:sales"</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s2">"bikes:sales"</span><span class="p">,</span> <span class="p">[</span><span class="mi">21</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; OK</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s2">"bikes:sales"</span><span class="p">,</span> <span class="p">[</span><span class="mi">150</span><span class="p">,</span> <span class="mi">95</span><span class="p">,</span> <span class="mi">75</span><span class="p">,</span> <span class="mi">34</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; OK</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">add</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"racer_ages"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="mf">45.88</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">44.2</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">58.03</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">19.76</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">39.84</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">69.28</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">50.97</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">25.41</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">19.27</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">85.71</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">42.63</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; OK</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">rank</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">,</span> <span class="mi">50</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [7]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">rank</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="mi">40</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [7, 4]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">quantile</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [44.2]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">byrank</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">,</span> <span class="mi">4</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [42.63]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">min</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 19.27</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">max</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 85.71</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">tdigest</span><span class="p">()</span><span class="o">.</span><span class="n">reset</span><span class="p">(</span><span class="s2">"racer_ages"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; OK</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_tdigest_tutorial-steptdig_reset')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_tdigest_tutorial-steptdig_reset" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_tdigest.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_tdigest_tutorial-steptdig_reset" name="tdigest_tutorial-steptdig_reset" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_tdigest_tutorial-steptdig_reset" title="Open example"> Node.js </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_reset" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_tdigest_tutorial-steptdig_reset" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">create</span><span class="p">(</span><span class="s1">'bikes:sales'</span><span class="p">,</span> <span class="mi">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s1">'bikes:sales'</span><span class="p">,</span> <span class="p">[</span><span class="mi">21</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s1">'bikes:sales'</span><span class="p">,</span> <span class="p">[</span><span class="mi">150</span><span class="p">,</span> <span class="mi">95</span><span class="p">,</span> <span class="mi">75</span><span class="p">,</span> <span class="mi">34</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">create</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">add</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">,</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="mf">45.88</span><span class="p">,</span> <span class="mf">44.2</span><span class="p">,</span> <span class="mf">58.03</span><span class="p">,</span> <span class="mf">19.76</span><span class="p">,</span> <span class="mf">39.84</span><span class="p">,</span> <span class="mf">69.28</span><span class="p">,</span> <span class="mf">50.97</span><span class="p">,</span> <span class="mf">25.41</span><span class="p">,</span> <span class="mf">19.27</span><span class="p">,</span> <span class="mf">85.71</span><span class="p">,</span> <span class="mf">42.63</span> </span></span><span class="line"><span class="cl"><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">rank</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">,</span> <span class="p">[</span><span class="mi">50</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [7] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">rank</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">,</span> <span class="p">[</span><span class="mi">50</span><span class="p">,</span> <span class="mi">40</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [7, 4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">quantile</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">,</span> <span class="p">[</span><span class="mf">0.5</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [44.2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">byRank</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">,</span> <span class="p">[</span><span class="mi">4</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [42.63] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">min</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 19.27 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">max</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 85.71 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">tDigest</span><span class="p">.</span><span class="nx">reset</span><span class="p">(</span><span class="s1">'racer_ages'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_tdigest_tutorial-steptdig_reset')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_tdigest_tutorial-steptdig_reset" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-tdigest.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_tdigest_tutorial-steptdig_reset" name="tdigest_tutorial-steptdig_reset" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_tdigest_tutorial-steptdig_reset" title="Open example"> Java </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_reset" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_tdigest_tutorial-steptdig_reset" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">TDigestExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">(){</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">unifiedJedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://127.0.0.1:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestCreate</span><span class="o">(</span><span class="s">"bikes:sales"</span><span class="o">,</span> <span class="mi">100</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; True </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestAdd</span><span class="o">(</span><span class="s">"bikes:sales"</span><span class="o">,</span> <span class="mi">21</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestAdd</span><span class="o">(</span><span class="s">"bikes:sales"</span><span class="o">,</span> <span class="mi">150</span><span class="o">,</span> <span class="mi">95</span><span class="o">,</span> <span class="mi">75</span><span class="o">,</span> <span class="mi">34</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestCreate</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; True </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestAdd</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">,</span> <span class="mf">45.88</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">44.2</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">58.03</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">19.76</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">39.84</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">69.28</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">50.97</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">25.41</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">19.27</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">85.71</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">42.63</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestRank</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">,</span> <span class="mi">50</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [7] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestRank</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">,</span> <span class="mi">50</span><span class="o">,</span> <span class="mi">40</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [7, 4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Double</span><span class="o">&gt;</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestQuantile</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">,</span> <span class="mf">0.5</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [44.2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Double</span><span class="o">&gt;</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestByRank</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">,</span> <span class="mi">4</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [42.63] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestMin</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 19.27 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestMax</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 85.71 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">unifiedJedis</span><span class="o">.</span><span class="na">tdigestReset</span><span class="o">(</span><span class="s">"racer_ages"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_tdigest_tutorial-steptdig_reset')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_tdigest_tutorial-steptdig_reset" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/TDigestExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_tdigest_tutorial-steptdig_reset" name="tdigest_tutorial-steptdig_reset" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_tdigest_tutorial-steptdig_reset" title="Open example"> Go </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_reset" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_tdigest_tutorial-steptdig_reset" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_tdigstart</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestCreate</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:sales"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:sales"</span><span class="p">,</span> <span class="mi">21</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:sales"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mi">150</span><span class="p">,</span> <span class="mi">95</span><span class="p">,</span> <span class="mi">75</span><span class="p">,</span> <span class="mi">34</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_tdigcdf</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestCreate</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">45.88</span><span class="p">,</span> <span class="mf">44.2</span><span class="p">,</span> <span class="mf">58.03</span><span class="p">,</span> <span class="mf">19.76</span><span class="p">,</span> <span class="mf">39.84</span><span class="p">,</span> <span class="mf">69.28</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">50.97</span><span class="p">,</span> <span class="mf">25.41</span><span class="p">,</span> <span class="mf">19.27</span><span class="p">,</span> <span class="mf">85.71</span><span class="p">,</span> <span class="mf">42.63</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> <span class="mi">50</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [7] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> <span class="mi">50</span><span class="p">,</span> <span class="mi">40</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [7 4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_tdigquant</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestCreate</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">45.88</span><span class="p">,</span> <span class="mf">44.2</span><span class="p">,</span> <span class="mf">58.03</span><span class="p">,</span> <span class="mf">19.76</span><span class="p">,</span> <span class="mf">39.84</span><span class="p">,</span> <span class="mf">69.28</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">50.97</span><span class="p">,</span> <span class="mf">25.41</span><span class="p">,</span> <span class="mf">19.27</span><span class="p">,</span> <span class="mf">85.71</span><span class="p">,</span> <span class="mf">42.63</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestQuantile</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [44.2] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestByRank</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> <span class="mi">4</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [42.63] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_tdigmin</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestCreate</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">45.88</span><span class="p">,</span> <span class="mf">44.2</span><span class="p">,</span> <span class="mf">58.03</span><span class="p">,</span> <span class="mf">19.76</span><span class="p">,</span> <span class="mf">39.84</span><span class="p">,</span> <span class="mf">69.28</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mf">50.97</span><span class="p">,</span> <span class="mf">25.41</span><span class="p">,</span> <span class="mf">19.27</span><span class="p">,</span> <span class="mf">85.71</span><span class="p">,</span> <span class="mf">42.63</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestMin</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 19.27 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestMax</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 85.71 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_tdigreset</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestCreate</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">TDigestReset</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"racer_ages"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_tdigest_tutorial-steptdig_reset')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_tdigest_tutorial-steptdig_reset" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/tdigest_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_tdigest_tutorial-steptdig_reset" name="tdigest_tutorial-steptdig_reset" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_tdigest_tutorial-steptdig_reset" title="Open example"> C# </label> <div aria-labelledby="tab-tdigest_tutorial-steptdig_reset" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_tdigest_tutorial-steptdig_reset" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.RedisStackCommands</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">Tdigest_tutorial</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Create</span><span class="p">(</span><span class="s">"bikes:sales"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Add</span><span class="p">(</span><span class="s">"bikes:sales"</span><span class="p">,</span> <span class="m">21</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Add</span><span class="p">(</span><span class="s">"bikes:sales"</span><span class="p">,</span> <span class="m">150</span><span class="p">,</span> <span class="m">95</span><span class="p">,</span> <span class="m">75</span><span class="p">,</span> <span class="m">34</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; true</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'tdig_start' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Create</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Add</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">45.88</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">44.2</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">58.03</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">19.76</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">39.84</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">69.28</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">50.97</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">25.41</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">19.27</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">85.71</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">42.63</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span><span class="p">[]</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Rank</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">,</span> <span class="m">50</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res6</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 7</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span><span class="p">[]</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Rank</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">,</span> <span class="m">50</span><span class="p">,</span> <span class="m">40</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res7</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 7, 4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'tdig_cdf' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double</span><span class="p">[]</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Quantile</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">,</span> <span class="m">0.5</span><span class="p">);</span> <span class="p">;</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res8</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 44.2</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double</span><span class="p">[]</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">ByRank</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">,</span> <span class="m">4</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res9</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 42.63</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'tdig_quant' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Min</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res10</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 19.27</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Max</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 85.71</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'tdig_min' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">bool</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">TDIGEST</span><span class="p">().</span><span class="n">Reset</span><span class="p">(</span><span class="s">"racer_ages"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'tdig_reset' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_tdigest_tutorial-steptdig_reset')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_tdigest_tutorial-steptdig_reset" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/Tdigest_tutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <h2 id="academic-sources"> Academic sources </h2> <ul> <li> <a href="https://www.sciencedirect.com/science/article/pii/S2665963820300403"> The <em> t </em> -digest: Efficient estimates of distributions </a> </li> </ul> <h2 id="references"> References </h2> <ul> <li> <a href="https://redis.com/blog/t-digest-in-redis-stack/"> t-digest: A New Probabilistic Data Structure in Redis Stack </a> </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/data-types/probabilistic/t-digest/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rc/security/access-control/saml-sso/saml-integration-auth0/.html
<section class="prose w-full py-12 max-w-none"> <h1> Auth0 SAML integration guide </h1> <p class="text-lg -mt-5 mb-10"> This integration guide shows how to configure Auth0 as a SAML single sign on provider for your Redis Cloud account. </p> <p> This guide shows how to configure <a href="https://auth0.com/docs"> Auth0 </a> as a SAML single sign-on identity provider (IdP) for your Redis Cloud account. </p> <p> To learn more about Redis Cloud support for SAML, see <a href="/docs/latest/operate/rc/security/access-control/saml-sso/"> SAML single sign-on </a> . </p> <p> Before completing this guide, you must <a href="/docs/latest/operate/rc/security/access-control/saml-sso/#verify-domain"> verify ownership of any domains </a> you want to associate with your SAML setup. </p> <h2 id="step-1-set-up-your-identity-provider-idp"> Step 1: Set up your identity provider (IdP) </h2> <h3 id="specify-the-saml-owner"> Specify the SAML owner </h3> <ol> <li> <p> Sign in to your Auth0 account and navigate to <strong> User Management &gt; Users </strong> . </p> <ul> <li> Select the SAML owner. </li> <li> Verify the details. </li> </ul> <p> SAML assertion requires first and last name, which are not available in the default user profile. </p> <blockquote> <p> <strong> Note </strong> : Depending how they are created, users can have different profiles. </p> </blockquote> <a href="/docs/latest/images/rc/saml/auth0_saml_1.png" sdata-lightbox="/images/rc/saml/auth0_saml_1.png"> <img src="/docs/latest/images/rc/saml/auth0_saml_1.png"/> </a> </li> <li> <p> Add <code> user_metadata </code> to fulfill the SAML assertion, then select <strong> Save </strong> . </p> <a href="/docs/latest/images/rc/saml/auth0_saml_2.png" sdata-lightbox="/images/rc/saml/auth0_saml_2.png"> <img src="/docs/latest/images/rc/saml/auth0_saml_2.png"/> </a> <p> The key-value pair of <code> redisAccountMapping </code> consists of a lowercase role name (owner, member, manager, billing_admin, or viewer) and your Redis Cloud Account ID found in the <a href="/docs/latest/operate/rc/accounts/account-settings/"> account settings </a> . </p> <pre tabindex="0"><code>{ "FirstName": "Test", "LastName": "User", "redisAccountMapping": "YOUR_REDIS_CLOUD_ID=owner" } </code></pre> </li> <li> <p> Open <strong> Auth Pipeline &gt; Rules </strong> and select <strong> Create </strong> . </p> <a href="/docs/latest/images/rc/saml/auth0_saml_3.png" sdata-lightbox="/images/rc/saml/auth0_saml_3.png"> <img src="/docs/latest/images/rc/saml/auth0_saml_3.png"/> </a> </li> <li> <p> Pick a rule template then select <strong> Empty rule </strong> . </p> </li> <li> <p> Provide a <strong> name </strong> for the rule and add the following script. </p> <pre tabindex="0"><code>function mapSamlAttributes(user, context, callback) { user.user_metadata = user.user_metadata || {}; context.samlConfiguration.mappings = { "Email": "email", "LastName": "user_metadata.LastName", "FirstName": "user_metadata.FirstName", "redisAccountMapping": "user_metadata.redisAccountMapping" }; callback(null, user, context); } </code></pre> </li> <li> <p> Select <strong> Save Changes </strong> . </p> <a href="/docs/latest/images/rc/saml/auth0_saml_4.png" sdata-lightbox="/images/rc/saml/auth0_saml_4.png"> <img src="/docs/latest/images/rc/saml/auth0_saml_4.png"/> </a> </li> </ol> <h3 id="create-and-configure-the-saml-application"> Create and configure the SAML application </h3> <ol> <li> <p> Open <strong> Applications &gt; Applications </strong> and select <strong> Create Application </strong> . </p> <a href="/docs/latest/images/rc/saml/auth0_saml_5.png" sdata-lightbox="/images/rc/saml/auth0_saml_5.png"> <img src="/docs/latest/images/rc/saml/auth0_saml_5.png"/> </a> </li> <li> <p> Provide a <strong> name </strong> for the Application and select <strong> Single Page Web Applications </strong> . Select <strong> Create </strong> . </p> <a href="/docs/latest/images/rc/saml/auth0_saml_6.png" sdata-lightbox="/images/rc/saml/auth0_saml_6.png"> <img src="/docs/latest/images/rc/saml/auth0_saml_6.png"/> </a> </li> <li> <p> From the newly created application, go to <strong> Settings &gt; Advanced Settings &gt; Certificates </strong> . </p> <ul> <li> Copy and save the <strong> Signing Certificate </strong> . You will need this information to configure SAML in admin console. </li> </ul> <a href="/docs/latest/images/rc/saml/auth0_saml_7.png" sdata-lightbox="/images/rc/saml/auth0_saml_7.png"> <img src="/docs/latest/images/rc/saml/auth0_saml_7.png"/> </a> <ul> <li> We suggest that you update the default logo of the application to the Redis icon for better visibility. </li> </ul> </li> <li> <p> From the newly created application, go to <strong> Addons </strong> and enable <strong> SAML 2 WEB APP </strong> . </p> <a href="/docs/latest/images/rc/saml/auth0_saml_8.png" sdata-lightbox="/images/rc/saml/auth0_saml_8.png"> <img src="/docs/latest/images/rc/saml/auth0_saml_8.png"/> </a> </li> <li> <p> From the <strong> Usage </strong> tab: </p> <ul> <li> Copy and save the <strong> Issuer </strong> value. </li> <li> Copy and save the <strong> Identity Provider Login URL </strong> . </li> </ul> <p> You will need both of these values, along with the certificate value you copied in the previous step, to configure SAML in admin console. </p> <a href="/docs/latest/images/rc/saml/auth0_saml_9.png" sdata-lightbox="/images/rc/saml/auth0_saml_9.png"> <img src="/docs/latest/images/rc/saml/auth0_saml_9.png"/> </a> </li> </ol> <h2 id="step-2-configure-saml-support-in-redis-cloud"> Step 2: Configure SAML support in Redis Cloud </h2> <p> Now that you have you Auth0 IdP server ready, configure support for SAML in Redis Cloud. </p> <h3 id="sign-in-to-redis-cloud"> Sign in to Redis Cloud </h3> <p> Sign in to your account on the <a href="https://cloud.redis.io/#/login"> Redis Cloud console </a> . </p> <h3 id="activate-saml-in-access-management"> Activate SAML in Access Management </h3> <p> To activate SAML, you need to have a local user (or social sign-on user) with the <strong> owner </strong> role. If you have the correct permissions, you will see the <strong> Single Sign-On </strong> tab. </p> <ol> <li> <p> Fill in the information you saved previously in the <strong> setup </strong> form. This includes: </p> <ul> <li> <strong> Issuer (IdP Entity ID) </strong> : Issuer value from Auth0 </li> <li> <strong> IdP server URL </strong> : Identity Provider Login URL from Auth0 </li> <li> <strong> Assertion signing certificate </strong> : Certificate value from Auth0 </li> </ul> <a href="/docs/latest/images/rc/saml/sm_saml_1.png" sdata-lightbox="/images/rc/saml/sm_saml_1.png"> <img src="/docs/latest/images/rc/saml/sm_saml_1.png"/> </a> <p> Once you click <strong> Enable </strong> , wait a few seconds for the status to change. </p> </li> <li> <p> Download the service provider (SP) metadata. Save the file to your local hard disk. </p> <a href="/docs/latest/images/rc/saml/sm_saml_3.png" sdata-lightbox="/images/rc/saml/sm_saml_3.png"> <img src="/docs/latest/images/rc/saml/sm_saml_3.png"/> </a> </li> <li> <p> Open the file in any text editor. Save the following text from the metadata: </p> <ul> <li> <strong> EntityID </strong> : The unique name of the service provider (SP) </li> </ul> <a href="/docs/latest/images/rc/saml/sm_saml_4.png" sdata-lightbox="/images/rc/saml/sm_saml_4.png"> <img src="/docs/latest/images/rc/saml/sm_saml_4.png"/> </a> <ul> <li> <strong> Location </strong> : The location of the assertion consumer service </li> </ul> <a href="/docs/latest/images/rc/saml/sm_saml_5.png" sdata-lightbox="/images/rc/saml/sm_saml_5.png"> <img src="/docs/latest/images/rc/saml/sm_saml_5.png"/> </a> </li> </ol> <h2 id="step-3-finish-saml-configuration-in-auth0"> Step 3: Finish SAML configuration in Auth0 </h2> <ol> <li> <p> Return to the Auth0 SAML application and select <strong> Addons &gt; Settings </strong> : </p> <a href="/docs/latest/images/rc/saml/auth0_saml_10.png" sdata-lightbox="/images/rc/saml/auth0_saml_10.png"> <img src="/docs/latest/images/rc/saml/auth0_saml_10.png"/> </a> <ul> <li> <p> Paste the <strong> Location </strong> link in <strong> Application Callback URL </strong> field. </p> </li> <li> <p> To update the <strong> Settings </strong> code area, add this code. Modify the <code> audience </code> variable with the <code> EntityID </code> value from the metadata file you downloaded. Also, modify the <code> recipient </code> variable with the <code> Location </code> value from the metadata file you downloaded. </p> </li> </ul> <pre tabindex="0"><code>{ "audience": "ENTITYID VALUE FROM FILE", "recipient": "LOCATION VALUE FROM FILE", "passthroughClaimsWithNoMapping": false, "nameIdentifierProbes": [ "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress" ] } </code></pre> <p> Scroll down and select <strong> Save </strong> to apply the configuration. </p> </li> </ol> <h3 id="idp-initiated-sso"> IdP initiated SSO </h3> <p> To use IdP-initiated SSO with certain identity providers, you also need to set the <code> RelayState </code> parameter to this URL: </p> <p> <code> https://cloud.redis.io/#/login/?idpId=&lt;ID&gt; </code> </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> Replace <code> ID </code> so it matches the <code> AssertionConsumerService </code> Location URL ID (the content after the last forward slash "/"). To learn more about how to configure service provider apps, see your identity provider’s documentation. </div> </div> <h2 id="step-4-return-to-the-redis-cloud-console"> Step 4: Return to the Redis Cloud console </h2> <ol> <li> <p> Return to the Redis Cloud console and select <strong> Activate </strong> . </p> <a href="/docs/latest/images/rc/saml/sm_saml_8.png" sdata-lightbox="/images/rc/saml/sm_saml_8.png"> <img src="/docs/latest/images/rc/saml/sm_saml_8.png"/> </a> <p> A popup appears, explaining that, in order to test the SAML connection, that we need to login with credentials of a user defined in Auth0. </p> <a href="/docs/latest/images/rc/saml/sm_saml_9.png" sdata-lightbox="/images/rc/saml/sm_saml_9.png"> <img src="/docs/latest/images/rc/saml/sm_saml_9.png"/> </a> </li> <li> <p> The Auth0 login screen appears. Enter the credentials and select <strong> Sign In </strong> . </p> <a href="/docs/latest/images/rc/saml/auth0_saml_12.png" sdata-lightbox="/images/rc/saml/auth0_saml_12.png"> <img src="/docs/latest/images/rc/saml/auth0_saml_12.png"/> </a> </li> <li> <p> If the test has succeeded, you will see the the Redis Cloud console screen. Your local account is now considered a SAML account. To log in to the Redis Cloud console from now on, click on <strong> Sign in with SSO </strong> . </p> </li> <li> <p> Enter your SAML email and select <strong> Login </strong> . </p> </li> </ol> <p> You have successfully configured SAML as an identification provider. </p> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rc/security/access-control/saml-sso/saml-integration-auth0/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/integrate/redis-data-integration/data-pipelines/transform-examples/redis-hash-example/.html
<section class="prose w-full py-12 max-w-none"> <h1> Write to a Redis hash </h1> <p> In the following example, the data is captured from the source table named <code> invoice </code> and is written to the Redis database as hash keys. The <code> connection </code> is an optional parameter that refers to the corresponding connection name defined in <code> config.yaml </code> . When you specify the <code> data_type </code> parameter for the job, it overrides the system-wide setting <code> target_data_type </code> defined in <code> config.yaml </code> . </p> <p> In this case, the result will be Redis hashes with key names based on the key expression (for example, <code> invoice_id:1 </code> ) and with an expiration of 100 seconds. If you don't supply an <code> expire </code> parameter, the keys will never expire. </p> <div class="highlight"> <pre class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="nt">source</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">server_name</span><span class="p">:</span><span class="w"> </span><span class="l">chinook</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">schema</span><span class="p">:</span><span class="w"> </span><span class="l">public</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">table</span><span class="p">:</span><span class="w"> </span><span class="l">invoice</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">output</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">uses</span><span class="p">:</span><span class="w"> </span><span class="l">redis.write</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">with</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">connection</span><span class="p">:</span><span class="w"> </span><span class="l">target</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">data_type</span><span class="p">:</span><span class="w"> </span><span class="l">hash</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">key</span><span class="p">:</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">expression</span><span class="p">:</span><span class="w"> </span><span class="l">concat(['invoice_id:', InvoiceId])</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">language</span><span class="p">:</span><span class="w"> </span><span class="l">jmespath</span><span class="w"> </span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">expire</span><span class="p">:</span><span class="w"> </span><span class="m">100</span><span class="w"> </span></span></span></code></pre> </div> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/integrate/redis-data-integration/data-pipelines/transform-examples/redis-hash-example/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/databases/import-export/migrate-to-active-active/.html
<section class="prose w-full py-12 max-w-none"> <h1> Migrate a database to Active-Active </h1> <p class="text-lg -mt-5 mb-10"> Use Replica Of to migrate your database to an Active-Active database. </p> <p> If you have data in a single-region Redis Enterprise Software database that you want to migrate to an <a href="/docs/latest/operate/rs/databases/active-active/"> Active-Active database </a> , you'll need to create a new Active-Active database and migrate the data into the new database as a <a href="/docs/latest/operate/rs/databases/import-export/replica-of/"> Replica Of </a> the existing database. This process will gradually populate the data in the Active-Active database. </p> <p> Before data migration starts, all data is flushed from the Active-Active database. The data is migrated to the Active-Active instance where you configured migration, and the data from that instance is copied to the other Active-Active instances. </p> <p> When data migration is finished, turn off migration and connect your applications to the Active-Active database. </p> <a href="/docs/latest/images/rs/A-A_migration.png" sdata-lightbox="/images/rs/A-A_migration.png"> <img alt="Active-Active data migration process" src="/docs/latest/images/rs/A-A_migration.png" width="75%"/> </a> <h2 id="prerequisites"> Prerequisites </h2> <ul> <li> <p> During the migration, any applications that connect to the Active-Active database must be <strong> read-only </strong> to ensure the dataset is identical to the source database during the migration process. However, you can continue to write to the source database during the migration process. </p> </li> <li> <p> If you used the mDNS protocol for the cluster name (FQDN), the <a href="/docs/latest/operate/rs/networking/mdns/"> client mDNS prerequisites </a> must be met in order to communicate with other clusters. </p> </li> </ul> <h2 id="migrate-from-a-redis-enterprise-cluster"> Migrate from a Redis Enterprise cluster </h2> <p> You can migrate a Redis Enterprise database from the <a href="#migrate-from-the-same-cluster"> same cluster </a> or a <a href="#migrate-from-a-different-cluster"> different cluster </a> . </p> <h3 id="migrate-from-the-same-cluster"> Migrate from the same cluster </h3> <p> To migrate a database to Active-Active in the same Redis Enterprise cluster: </p> <ol> <li> <p> Create a new Active-Active database. For prerequisites and detailed instructions, see <a href="/docs/latest/operate/rs/databases/active-active/create/"> Create an Active-Active geo-replicated database </a> . </p> </li> <li> <p> After the Active-Active database is active, click <strong> Edit </strong> on the <strong> Configuration </strong> screen. </p> </li> <li> <p> Expand the <strong> Migrate to Active-Active </strong> section: </p> <a href="/docs/latest/images/rs/screenshots/databases/migrate-to-active-active/migrate-to-active-active-section.png" sdata-lightbox="/images/rs/screenshots/databases/migrate-to-active-active/migrate-to-active-active-section.png"> <img alt="Migrate to Active-Active section." src="/docs/latest/images/rs/screenshots/databases/migrate-to-active-active/migrate-to-active-active-section.png"/> </a> </li> <li> <p> Click <strong> + Add source database </strong> . </p> </li> <li> <p> In the <strong> Migrate to Active-Active </strong> dialog, select <strong> Current cluster </strong> : </p> <a href="/docs/latest/images/rs/screenshots/databases/migrate-to-active-active/migrate-to-active-active-dialog-current-cluster.png" sdata-lightbox="/images/rs/screenshots/databases/migrate-to-active-active/migrate-to-active-active-dialog-current-cluster.png"> <img alt="Migrate to Active-Active dialog with Current cluster tab selected." src="/docs/latest/images/rs/screenshots/databases/migrate-to-active-active/migrate-to-active-active-dialog-current-cluster.png"/> </a> </li> <li> <p> Select the source database from the list. </p> </li> <li> <p> Click <strong> Add source </strong> . </p> </li> <li> <p> Click <strong> Save </strong> . </p> </li> </ol> <h3 id="migrate-from-a-different-cluster"> Migrate from a different cluster </h3> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> For a source database on a different Redis Enterprise Software cluster, you can <a href="/docs/latest/operate/rs/databases/import-export/replica-of/#data-compression-for-replica-of"> compress the replication data </a> to save bandwidth. </div> </div> <p> To migrate a database to Active-Active in different Redis Enterprise clusters: </p> <ol> <li> <p> Sign in to the Cluster Manager UI of the cluster hosting the source database. </p> <ol> <li> <p> In <strong> Databases </strong> , select the source database and then select the <strong> Configuration </strong> tab. </p> </li> <li> <p> In the <strong> Replica Of </strong> section, select <strong> Use this database as a source for another database </strong> . </p> </li> <li> <p> Copy the Replica Of source URL. </p> <a href="/docs/latest/images/rs/screenshots/databases/config-replica-of-copy-source-url.png" sdata-lightbox="/images/rs/screenshots/databases/config-replica-of-copy-source-url.png"> <img alt="Copy the Replica Of source URL from the Connection link to destination dialog." src="/docs/latest/images/rs/screenshots/databases/config-replica-of-copy-source-url.png"/> </a> <p> To change the internal password, select <strong> Regenerate password </strong> . </p> <p> If you regenerate the password, replication to existing destinations fails until their credentials are updated with the new password. </p> </li> </ol> </li> <li> <p> Sign in to the Cluster Manager UI of the destination database’s cluster. </p> </li> <li> <p> Create a new Active-Active database. For prerequisites and detailed instructions, see <a href="/docs/latest/operate/rs/databases/active-active/create/"> Create an Active-Active geo-replicated database </a> . </p> </li> <li> <p> After the Active-Active database is active, click <strong> Edit </strong> on the <strong> Configuration </strong> screen. </p> </li> <li> <p> Expand the <strong> Migrate to Active-Active </strong> section: </p> <a href="/docs/latest/images/rs/screenshots/databases/migrate-to-active-active/migrate-to-active-active-section.png" sdata-lightbox="/images/rs/screenshots/databases/migrate-to-active-active/migrate-to-active-active-section.png"> <img alt="Migrate to Active-Active section." src="/docs/latest/images/rs/screenshots/databases/migrate-to-active-active/migrate-to-active-active-section.png"/> </a> </li> <li> <p> Click <strong> + Add source database </strong> . </p> </li> <li> <p> In the <strong> Migrate to Active-Active </strong> dialog, select <strong> External </strong> : </p> <a href="/docs/latest/images/rs/screenshots/databases/migrate-to-active-active/migrate-to-active-active-dialog-external.png" sdata-lightbox="/images/rs/screenshots/databases/migrate-to-active-active/migrate-to-active-active-dialog-external.png"> <img alt="Migrate to Active-Active dialog with External tab selected." src="/docs/latest/images/rs/screenshots/databases/migrate-to-active-active/migrate-to-active-active-dialog-external.png"/> </a> </li> <li> <p> For <strong> Source database URL </strong> , enter the Replica Of source URL you copied in step 1. </p> </li> <li> <p> Click <strong> Add source </strong> . </p> </li> <li> <p> Click <strong> Save </strong> . </p> </li> </ol> <h2 id="migrate-from-redis-community-edition"> Migrate from Redis Community Edition </h2> <p> To migrate a Redis Community Edition database to Active-Active: </p> <ol> <li> <p> Create a new Active-Active database. For prerequisites and detailed instructions, see <a href="/docs/latest/operate/rs/databases/active-active/create/"> Create an Active-Active geo-replicated database </a> . </p> </li> <li> <p> After the Active-Active database is active, click <strong> Edit </strong> on the <strong> Configuration </strong> screen. </p> </li> <li> <p> Expand the <strong> Migrate to Active-Active </strong> section: </p> <a href="/docs/latest/images/rs/screenshots/databases/migrate-to-active-active/migrate-to-active-active-section.png" sdata-lightbox="/images/rs/screenshots/databases/migrate-to-active-active/migrate-to-active-active-section.png"> <img alt="Migrate to Active-Active section." src="/docs/latest/images/rs/screenshots/databases/migrate-to-active-active/migrate-to-active-active-section.png"/> </a> </li> <li> <p> Click <strong> + Add source database </strong> . </p> </li> <li> <p> In the <strong> Migrate to Active-Active </strong> dialog, select <strong> External </strong> : </p> <a href="/docs/latest/images/rs/screenshots/databases/migrate-to-active-active/migrate-to-active-active-dialog-external.png" sdata-lightbox="/images/rs/screenshots/databases/migrate-to-active-active/migrate-to-active-active-dialog-external.png"> <img alt="Migrate to Active-Active dialog with External tab selected." src="/docs/latest/images/rs/screenshots/databases/migrate-to-active-active/migrate-to-active-active-dialog-external.png"/> </a> </li> <li> <p> Enter the <strong> Source database URL </strong> : </p> <ul> <li> <p> If the database has a password: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">redis://:&lt;password&gt;@&lt;host&gt;:&lt;port&gt; </span></span></code></pre> </div> <p> Where the password is the Redis password represented with URL encoding escape characters. </p> </li> <li> <p> If the database does not have a password: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">redis://&lt;host&gt;:&lt;port&gt; </span></span></code></pre> </div> </li> </ul> </li> <li> <p> Click <strong> Add source </strong> . </p> </li> <li> <p> Click <strong> Save </strong> . </p> </li> </ol> <h2 id="stop-sync-after-migration"> Stop sync after migration </h2> <ol> <li> <p> Wait until the migration is complete, indicated by the <strong> Status </strong> <em> Synced </em> . </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> Migration can take minutes to hours to complete depending on the dataset size and network quality. </div> </div> </li> <li> <p> On the Active-Active database's <strong> Configuration </strong> screen, click <strong> Edit </strong> . </p> </li> <li> <p> In the <strong> Migrate to Active-Active </strong> section, click <strong> Stop sync </strong> : </p> <a href="/docs/latest/images/rs/screenshots/databases/migrate-to-active-active/migrate-to-active-active-synced.png" sdata-lightbox="/images/rs/screenshots/databases/migrate-to-active-active/migrate-to-active-active-synced.png"> <img alt="The Migrate to Active-Active section shows the Active-Active database is synced with the source database." src="/docs/latest/images/rs/screenshots/databases/migrate-to-active-active/migrate-to-active-active-synced.png"/> </a> </li> <li> <p> In the <strong> Stop synchronization </strong> dialog, click <strong> Stop </strong> to proceed. </p> </li> <li> <p> Redirect client connections to the Active-Active database after <strong> Status </strong> changes to <em> Sync stopped </em> : </p> <a href="/docs/latest/images/rs/screenshots/databases/migrate-to-active-active/migrate-to-active-active-sync-stopped.png" sdata-lightbox="/images/rs/screenshots/databases/migrate-to-active-active/migrate-to-active-active-sync-stopped.png"> <img alt="The Migrate to Active-Active section shows the Active-Active database stopped syncing with the source database." src="/docs/latest/images/rs/screenshots/databases/migrate-to-active-active/migrate-to-active-active-sync-stopped.png"/> </a> </li> </ol> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/databases/import-export/migrate-to-active-active/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/develop/get-started/rag/.html
<section class="prose w-full py-12"> <h1> RAG with Redis </h1> <p class="text-lg -mt-5 mb-10"> Understand how to use Redis for RAG use cases </p> <h3 id="what-is-retrieval-augmented-generation-rag"> What is Retrieval Augmented Generation (RAG)? </h3> <p> Large Language Models (LLMs) generate human-like text but are limited by the data they were trained on. RAG enhances LLMs by integrating them with external, domain-specific data stored in a Redis <a href="/docs/latest/develop/get-started/vector-database/"> vector database </a> . </p> <p> RAG involves three main steps: </p> <ul> <li> <strong> Retrieve </strong> : Fetch relevant information from Redis using vector search and filters based on the user query. </li> <li> <strong> Augment </strong> : Create a prompt for the LLM, including the user query, relevant context, and additional instructions. </li> <li> <strong> Generate </strong> : Return the response generated by the LLM to the user. </li> </ul> <p> RAG enables LLMs to use real-time information, improving the accuracy and relevance of generated content. Redis is ideal for RAG due to its speed, versatility, and familiarity. </p> <h3 id="the-role-of-redis-in-rag"> The role of Redis in RAG </h3> <p> Redis provides a robust platform for managing real-time data. It supports the storage and retrieval of vectors, essential for handling large-scale, unstructured data and performing similarity searches. Key features and components of Redis that make it suitable for RAG include: </p> <ol> <li> <strong> Vector database </strong> : Stores and indexes vector embeddings that semantically represent unstructured data. </li> <li> <strong> Semantic cache </strong> : Caches frequently asked questions (FAQs) in a RAG pipeline. Using vector search, Redis retrieves similar previously answered questions, reducing LLM inference costs and latency. </li> <li> <strong> LLM session manager </strong> : Stores conversation history between an LLM and a user. Redis fetches recent and relevant portions of the chat history to provide context, improving the quality and accuracy of responses. </li> <li> <strong> High performance and scalability </strong> : Known for its <a href="https://redis.io/blog/benchmarking-results-for-vector-databases/"> low latency and high throughput </a> , Redis is ideal for RAG systems and AI agents requiring rapid data retrieval and generation. </li> </ol> <h3 id="build-a-rag-application-with-redis"> Build a RAG Application with Redis </h3> <p> To build a RAG application with Redis, follow these general steps: </p> <ol> <li> <p> <strong> Set up Redis </strong> : Start by setting up a Redis instance and configuring it to handle vector data. </p> </li> <li> <p> <strong> Use a Framework </strong> : </p> <ol> <li> <strong> Redis Vector Library (RedisVL) </strong> : <a href="https://redis.io/docs/latest/integrate/redisvl/"> RedisVL </a> enhances the development of generative AI applications by efficiently managing vectors and metadata. It allows for storage of vector embeddings and facilitates fast similarity searches, crucial for retrieving relevant information in RAG. </li> <li> <strong> Popular AI frameworks </strong> : Redis integrates seamlessly with various AI frameworks and tools. For instance, combining Redis with <a href="https://python.langchain.com/v0.2/docs/integrations/vectorstores/redis/"> LangChain </a> or <a href="https://docs.llamaindex.ai/en/latest/examples/vector_stores/RedisIndexDemo/"> LlamaIndex </a> , libraries for building language models, enables developers to create sophisticated RAG pipelines. These integrations support efficient data management and building real-time LLM chains. </li> <li> <strong> Spring AI and Redis </strong> : Using <a href="https://redis.io/blog/building-a-rag-application-with-redis-and-spring-ai/"> Spring AI with Redis </a> simplifies building RAG applications. Spring AI provides a structured approach to integrating AI capabilities into applications, while Redis handles data management, ensuring the RAG pipeline is efficient and scalable. </li> </ol> </li> <li> <p> <strong> Embed and store data </strong> : Convert your data into vector embeddings using a suitable model (e.g., BERT, GPT). Store these embeddings in Redis, where they can be quickly retrieved based on vector searches. </p> </li> <li> <p> <strong> Integrate with a generative model </strong> : Use a generative AI model that can leverage the retrieved data. The model will use the vectors stored in Redis to augment its generation process, ensuring the output is informed by relevant, up-to-date information. </p> </li> <li> <p> <strong> Query and generate </strong> : Implement the query logic to retrieve relevant vectors from Redis based on the input prompt. Feed these vectors into the generative model to produce augmented outputs. </p> </li> </ol> <h3 id="benefits-of-using-redis-for-rag"> Benefits of Using Redis for RAG </h3> <ul> <li> <strong> Efficiency </strong> : The in-memory data store of Redis ensures that retrieval operations are performed with minimal latency. </li> <li> <strong> Scalability </strong> : Redis scales horizontally, seamlessly handling growing volumes of data and queries. </li> <li> <strong> Flexibility </strong> : Redis supports a variety of data structures and integrates with AI frameworks. </li> </ul> <p> In summary, Redis offers a powerful and efficient platform for implementing RAG. Its vector management capabilities, high performance, and seamless integration with AI frameworks make it an ideal choice for enhancing generative AI applications with real-time data retrieval. </p> <h3 id="resources"> Resources </h3> <ul> <li> <a href="https://redis.io/glossary/retrieval-augmented-generation/"> RAG defined </a> . </li> <li> <a href="https://redis.io/kb/doc/2ok7xd1drq/how-to-perform-retrieval-augmented-generation-rag-with-redis"> RAG overview </a> . </li> <li> <a href="https://redis.io/docs/latest/integrate/redisvl/"> Redis Vector Library (RedisVL) </a> and <a href="https://redis.io/blog/introducing-the-redis-vector-library-for-enhancing-genai-development/"> introductory article </a> . </li> <li> <a href="https://redis.io/blog/building-a-rag-application-with-redis-and-spring-ai/"> RAG with Redis and SpringAI </a> </li> <li> <a href="https://redis.io/blog/explore-the-new-multimodal-rag-template-from-langchain-and-redis/"> Build a multimodal RAG app with LangChain and Redis </a> </li> <li> <a href="https://github.com/redis-developer/redis-ai-resources"> Get hands-on with advanced Redis AI Recipes </a> </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/get-started/rag/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/ft.aliasdel/.html
<section class="prose w-full py-12"> <h1 class="command-name"> FT.ALIASDEL </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">FT.ALIASDEL alias </pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available in: </dt> <dd class="m-0"> <a href="/docs/stack"> Redis Stack </a> / <a href="/docs/interact/search-and-query"> Search 1.0.0 </a> </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) </dd> </dl> <p> Remove an alias from an index </p> <p> <a href="#examples"> Examples </a> </p> <h2 id="required-arguments"> Required arguments </h2> <details open=""> <summary> <code> alias </code> </summary> <p> is index alias to be removed. </p> </details> <h2 id="return"> Return </h2> <p> FT.ALIASDEL returns a simple string reply <code> OK </code> if executed correctly, or an error reply otherwise. </p> <h2 id="examples"> Examples </h2> <details open=""> <summary> <b> Remove an alias from an index </b> </summary> <p> Remove an alias from an index. </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379&gt; FT.ALIASDEL <span class="nb">alias</span> </span></span><span class="line"><span class="cl">OK</span></span></code></pre> </div> </details> <h2 id="see-also"> See also </h2> <p> <a href="/docs/latest/commands/ft.aliasadd/"> <code> FT.ALIASADD </code> </a> | <a href="/docs/latest/commands/ft.aliasupdate/"> <code> FT.ALIASUPDATE </code> </a> </p> <h2 id="related-topics"> Related topics </h2> <p> <a href="/docs/latest/develop/interact/search-and-query/"> RediSearch </a> </p> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/ft.aliasdel/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/objects/bdb/dataset_import_sources/.html
<section class="prose w-full py-12 max-w-none"> <h1> BDB dataset import sources object </h1> <p class="text-lg -mt-5 mb-10"> Documents the bdb dataset_import_sources object used with Redis Enterprise Software REST API calls. </p> <p> You can import data to a database from the following location types: </p> <ul> <li> HTTP/S </li> <li> FTP </li> <li> SFTP </li> <li> Amazon S3 </li> <li> Google Cloud Storage </li> <li> Microsoft Azure Storage </li> <li> NAS/Local Storage </li> </ul> <p> The source file to import should be in the <a href="/docs/latest/operate/rs/7.4/databases/configure/database-persistence/"> RDB </a> format. It can also be in a compressed (gz) RDB file. </p> <p> Supply an array of dataset import source objects to import data from multiple files. </p> <h2 id="basic-parameters"> Basic parameters </h2> <p> For all import location objects, you need to specify the location type via the <code> type </code> field. </p> <table> <thead> <tr> <th> Location type </th> <th> "type" value </th> </tr> </thead> <tbody> <tr> <td> FTP/S </td> <td> "url" </td> </tr> <tr> <td> SFTP </td> <td> "sftp" </td> </tr> <tr> <td> Amazon S3 </td> <td> "s3" </td> </tr> <tr> <td> Google Cloud Storage </td> <td> "gs" </td> </tr> <tr> <td> Microsoft Azure Storage </td> <td> "abs" </td> </tr> <tr> <td> NAS/Local Storage </td> <td> "mount_point" </td> </tr> </tbody> </table> <h2 id="location-specific-parameters"> Location-specific parameters </h2> <p> Any additional required parameters may differ based on the import location type. </p> <h3 id="ftp"> FTP </h3> <table> <thead> <tr> <th> Key name </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> url </td> <td> string </td> <td> A URI that represents the FTP/S location with the following format: <code> ftp://user:password@host:port/path/ </code> . The user and password can be omitted if not needed. </td> </tr> </tbody> </table> <h3 id="sftp"> SFTP </h3> <table> <thead> <tr> <th> Key name </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> key </td> <td> string </td> <td> SSH private key to secure the SFTP server connection. If you do not specify an SSH private key, the autogenerated private key of the cluster is used and you must add the SSH public key of the cluster to the SFTP server configuration. (optional) </td> </tr> <tr> <td> sftp_url </td> <td> string </td> <td> SFTP URL in the format: <code> sftp://user:password@host[:port]/path/filename.rdb </code> . The default port number is 22 and the default path is '/'. </td> </tr> </tbody> </table> <h3 id="aws-s3"> AWS S3 </h3> <table> <thead> <tr> <th> Key name </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> access_key_id </td> <td> string </td> <td> The AWS Access Key ID with access to the bucket </td> </tr> <tr> <td> bucket_name </td> <td> string </td> <td> S3 bucket name </td> </tr> <tr> <td> region_name </td> <td> string </td> <td> Amazon S3 region name (optional) </td> </tr> <tr> <td> secret_access_key </td> <td> string </td> <td> The AWS Secret Access that matches the Access Key ID </td> </tr> <tr> <td> subdir </td> <td> string </td> <td> Path to the backup directory in the S3 bucket (optional) </td> </tr> </tbody> </table> <h3 id="google-cloud-storage"> Google Cloud Storage </h3> <table> <thead> <tr> <th> Key name </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> bucket_name </td> <td> string </td> <td> Cloud Storage bucket name </td> </tr> <tr> <td> client_email </td> <td> string </td> <td> Email address for the Cloud Storage client ID </td> </tr> <tr> <td> client_id </td> <td> string </td> <td> Cloud Storage client ID with access to the Cloud Storage bucket </td> </tr> <tr> <td> private_key </td> <td> string </td> <td> Private key for the Cloud Storage matching the private key ID </td> </tr> <tr> <td> private_key_id </td> <td> string </td> <td> Cloud Storage private key ID with access to the Cloud Storage bucket </td> </tr> <tr> <td> subdir </td> <td> string </td> <td> Path to the backup directory in the Cloud Storage bucket (optional) </td> </tr> </tbody> </table> <h3 id="azure-blob-storage"> Azure Blob Storage </h3> <table> <thead> <tr> <th> Key name </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> account_key </td> <td> string </td> <td> Access key for the storage account </td> </tr> <tr> <td> account_name </td> <td> string </td> <td> Storage account name with access to the container </td> </tr> <tr> <td> container </td> <td> string </td> <td> Blob Storage container name </td> </tr> <tr> <td> sas_token </td> <td> string </td> <td> Token to authenticate with shared access signature </td> </tr> <tr> <td> subdir </td> <td> string </td> <td> Path to the backup directory in the Blob Storage container (optional) </td> </tr> </tbody> </table> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> <code> account_key </code> and <code> sas_token </code> are mutually exclusive </div> </div> <h3 id="naslocal-storage"> NAS/Local Storage </h3> <table> <thead> <tr> <th> Key name </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> path </td> <td> string </td> <td> Path to the locally mounted filename to import. You must create the mount point on all nodes, and the <code> redislabs:redislabs </code> user must have read permissions on the local mount point. </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/objects/bdb/dataset_import_sources/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/integrate/redis-data-integration/troubleshooting/.html
<section class="prose w-full py-12 max-w-none"> <h1> Troubleshooting </h1> <p class="text-lg -mt-5 mb-10"> Solve and report simple problems with RDI </p> <p> The following sections explain how you can get extra information from Redis Data Integration (RDI) to help you solve problems that you may encounter. Redis support may also ask you to provide this information to help you resolve issues. </p> <h2 id="install-debug"> Debug information during installation </h2> <p> If the installer fails with an error, then try installing again with the log level set to <code> DEBUG </code> : </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">./install.sh -l DEBUG <span class="c1"># Installer script</span> </span></span><span class="line"><span class="cl">redis-di install -l DEBUG <span class="c1"># Install command</span> </span></span></code></pre> </div> <p> This gives you more detail about the installation steps and can often help you to pinpoint the source of the error. </p> <h2 id="rdi-logs"> RDI logs </h2> <p> By default, RDI records the following logs in the host VM file system at <code> /opt/rdi/logs </code> (or whichever path you specified during installation); </p> <table> <thead> <tr> <th style="text-align:left"> Filename </th> <th style="text-align:left"> Phase </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> <code> rdi_collector-collector-initializer.log </code> </td> <td style="text-align:left"> Initializing the collector. </td> </tr> <tr> <td style="text-align:left"> <code> rdi_collector-debezium-ssl-init.log </code> </td> <td style="text-align:left"> Establishing the connector SSL connections to the source and RDI database (if you are using SSL). </td> </tr> <tr> <td style="text-align:left"> <code> rdi_collector-collector-source.log </code> </td> <td style="text-align:left"> Collector <a href="/docs/latest/integrate/redis-data-integration/architecture/"> change data capture (CDC) </a> operations. </td> </tr> <tr> <td style="text-align:left"> <code> rdi_rdi-rdi-operator.log </code> </td> <td style="text-align:left"> Main <a href="/docs/latest/integrate/redis-data-integration/architecture/#how-rdi-is-deployed"> RDI control plane </a> component. </td> </tr> <tr> <td style="text-align:left"> <code> rdi_processor-processor.log </code> </td> <td style="text-align:left"> RDI stream processing. </td> </tr> </tbody> </table> <p> Logs are recorded at the minimum <code> INFO </code> level in a simple format that log analysis tools can use. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> Often during the initial sync phase, the collector source log will contain a message saying RDI is out of memory. This is not an error but an informative message to say that RDI is applying <em> backpressure </em> to the collector. See <a href="/docs/latest/integrate/redis-data-integration/architecture/#backpressure-mechanism"> Backpressure mechanism </a> in the Architecture guide for more information. </div> </div> <h2 id="dump-support-package"> Dump support package </h2> <p> If you need to send a comprehensive set of forensics data to Redis support, run the <a href="/docs/latest/integrate/redis-data-integration/reference/cli/redis-di-dump-support-package/"> <code> redis-di dump-support-package </code> </a> command from the CLI. </p> <p> This command gathers the following data: </p> <ul> <li> All the internal RDI components and their status </li> <li> All internal RDI configuration </li> <li> List of secret names used by RDI components (but not the secrets themselves) </li> <li> RDI logs </li> <li> RDI component versions </li> <li> Output from the <a href="/docs/latest/integrate/redis-data-integration/reference/cli/redis-di-status/"> <code> redis-di status </code> </a> command </li> <li> Text of the <code> config.yaml </code> file </li> <li> Text of the Job configuration files </li> <li> [optional] RDI DLQ streams content </li> <li> Rejected records along with the reason for their rejection (should not exist in production) </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/integrate/redis-data-integration/troubleshooting/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/databases/configure/oss-cluster-api/.html
<section class="prose w-full py-12 max-w-none"> <h1> Enable OSS Cluster API </h1> <p> Review <a href="/docs/latest/operate/rs/clusters/optimize/oss-cluster-api/"> Redis OSS Cluster API </a> to determine if you should enable this feature for your database. </p> <h2 id="prerequisites"> Prerequisites </h2> <p> The Redis OSS Cluster API is supported only when a database meets specific criteria. </p> <p> The database must: </p> <ul> <li> Use the standard <a href="/docs/latest/operate/rs/databases/durability-ha/clustering/#supported-hashing-policies"> hashing policy </a> . </li> <li> Have the <a href="/docs/latest/operate/rs/databases/configure/proxy-policy/"> proxy policy </a> set to either <em> All primary shards </em> or <em> All nodes </em> . </li> </ul> <p> In addition, the database must <em> not </em> : </p> <ul> <li> Use node <code> include </code> or <code> exclude </code> in the proxy policy. </li> <li> Use <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/search/"> RediSearch </a> , <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/timeseries/"> RedisTimeSeries </a> , or <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/gears-v1/"> RedisGears </a> modules. </li> </ul> <p> The OSS Cluster API setting applies to individual databases instead of the entire cluster. </p> <h2 id="enable-oss-cluster-api-support"> Enable OSS Cluster API support </h2> <p> You can use the Cluster Manager UI or the <code> rladmin </code> utility to enable OSS Cluster API support for a database. </p> <h3 id="cluster-manager-ui"> Cluster Manager UI </h3> <p> When you use the Cluster Manager UI to enable the OSS Cluster API, it automatically configures the <a href="/docs/latest/operate/rs/databases/configure/oss-cluster-api/#prerequisites"> prerequisites </a> . </p> <p> To enable the OSS Cluster API for an existing database in the Cluster Manager UI: </p> <ol> <li> <p> From the database's <strong> Configuration </strong> tab, select <strong> Edit </strong> . </p> </li> <li> <p> Expand the <strong> Clustering </strong> section. </p> </li> <li> <p> Select <strong> Enable sharding </strong> . </p> </li> <li> <p> Select <strong> OSS Cluster API </strong> . </p> <a href="/docs/latest/images/rs/screenshots/databases/config-clustering-oss-cluster-api-7-8-2.png" sdata-lightbox="/images/rs/screenshots/databases/config-clustering-oss-cluster-api-7-8-2.png"> <img alt="Use the *OSS Cluster API* setting to enable the API for the selected database." src="/docs/latest/images/rs/screenshots/databases/config-clustering-oss-cluster-api-7-8-2.png"/> </a> </li> <li> <p> Select <strong> Save </strong> . </p> </li> </ol> <p> You can also use the Cluster Manager UI to enable the setting when creating a new database. </p> <h3 id="command-line-rladmin"> Command line ( <code> rladmin </code> ) </h3> <p> You can use the <a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/"> <code> rladmin </code> utility </a> to enable the OSS Cluster API for Redis Enterprise Software databases, including Replica Of databases. </p> <p> For Active-Active (CRDB) databases, <a href="#active-active-databases"> use the crdb-cli utility </a> . </p> <p> Ensure the <a href="/docs/latest/operate/rs/databases/configure/oss-cluster-api/#prerequisites"> prerequisites </a> have been configured. Then, enable the OSS Cluster API for a Redis database from the command line: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ rladmin tune db &lt;database name or ID&gt; oss_cluster enabled </span></span></code></pre> </div> <p> To determine the current setting for a database from the command line, use <code> rladmin info db </code> to return the value of the <code> oss_cluster </code> setting. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ rladmin info db <span class="nb">test</span> <span class="p">|</span> grep oss_cluster: </span></span><span class="line"><span class="cl"> oss_cluster: enabled </span></span></code></pre> </div> <p> The OSS Cluster API setting applies to the specified database only; it does not apply to the cluster. </p> <h3 id="active-active-databases"> Active-Active databases </h3> <p> The OSS Cluster API setting applies to all instances of the Active-Active database across participating clusters. To enable the OSS Cluster API for Active-Active databases, use the <a href="#cluster-manager-ui"> Cluster Manager UI </a> or the <a href="/docs/latest/operate/rs/references/cli-utilities/crdb-cli/"> <code> crdb-cli </code> </a> utility. </p> <p> To create an Active-Active database and enable the OSS Cluster API with <code> crdb-cli </code> : </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ crdb-cli crdb create --name &lt;name&gt; <span class="se">\ </span></span></span><span class="line"><span class="cl"><span class="se"></span> --memory-size 10g --port &lt;port&gt; <span class="se">\ </span></span></span><span class="line"><span class="cl"><span class="se"></span> --sharding <span class="nb">true</span> --shards-count <span class="m">2</span> <span class="se">\ </span></span></span><span class="line"><span class="cl"><span class="se"></span> --replication <span class="nb">true</span> --oss-cluster <span class="nb">true</span> --proxy-policy all-master-shards <span class="se">\ </span></span></span><span class="line"><span class="cl"><span class="se"></span> --instance <span class="nv">fqdn</span><span class="o">=</span>&lt;fqdn&gt;,username<span class="o">=</span>&lt;user&gt;,password<span class="o">=</span>&lt;pass&gt; <span class="se">\ </span></span></span><span class="line"><span class="cl"><span class="se"></span> --instance <span class="nv">fqdn</span><span class="o">=</span>&lt;fqdn&gt;,username<span class="o">=</span>&lt;user&gt;,password<span class="o">=</span>&lt;pass&gt; <span class="se">\ </span></span></span><span class="line"><span class="cl"><span class="se"></span> --instance <span class="nv">fqdn</span><span class="o">=</span>&lt;fqdn&gt;,username<span class="o">=</span>&lt;user&gt;,password<span class="o">=</span>&lt;pass&gt; </span></span></code></pre> </div> <p> See the <a href="/docs/latest/operate/rs/references/cli-utilities/crdb-cli/crdb/create/"> <code> crdb-cli crdb create </code> </a> reference for more options. </p> <p> To enable the OSS Cluster API for an existing Active-Active database with <code> crdb-cli </code> : </p> <ol> <li> <p> Obtain the <code> CRDB-GUID </code> for the new database: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ crdb-cli crdb list </span></span><span class="line"><span class="cl">CRDB-GUID NAME REPL-ID CLUSTER-FQDN </span></span><span class="line"><span class="cl">&lt;CRDB-GUID&gt; Test <span class="m">4</span> cluster1.local </span></span></code></pre> </div> </li> <li> <p> Use the <code> CRDB-GUID </code> to enable the OSS Cluster API: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ crdb-cli crdb update --crdb-guid &lt;CRDB-GUID&gt; <span class="se">\ </span></span></span><span class="line"><span class="cl"><span class="se"></span> --oss-cluster <span class="nb">true</span> </span></span></code></pre> </div> </li> </ol> <h2 id="turn-off-oss-cluster-api-support"> Turn off OSS Cluster API support </h2> <p> To deactivate OSS Cluster API support for a database, either: </p> <ul> <li> <p> Use the Cluster Manager UI to turn off the <strong> OSS Cluster API </strong> in the <strong> Clustering </strong> section of the database <strong> Configuration </strong> settings. </p> </li> <li> <p> Use the appropriate utility to deactivate the OSS Cluster API setting. </p> <p> For standard databases, including Replica Of, use <code> rladmin </code> : </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ rladmin tune db &lt;name or ID&gt; oss_cluster disabled </span></span></code></pre> </div> <p> For Active-Active databases, use the Cluster Manager UI or <code> crdb-cli </code> : </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ crdb-cli crdb update --crdb-guid &lt;CRDB-GUID&gt; <span class="se">\ </span></span></span><span class="line"><span class="cl"><span class="se"></span> --oss-cluster <span class="nb">false</span> </span></span></code></pre> </div> </li> </ul> <h2 id="multi-key-command-support"> Multi-key command support </h2> <p> When you enable the OSS Cluster API for a database, <a href="/docs/latest/operate/rc/databases/configuration/clustering/#multikey-operations"> multi-key commands </a> are only allowed when all keys are mapped to the same slot. </p> <p> To verify that your database meets this requirement, make sure that the <code> CLUSTER KEYSLOT </code> reply is the same for all keys affected by the multi-key command. To learn more, see <a href="/docs/latest/operate/rs/databases/durability-ha/clustering/#multikey-operations"> multi-key operations </a> . </p> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/databases/configure/oss-cluster-api/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/zlexcount/.html
<section class="prose w-full py-12"> <h1 class="command-name"> ZLEXCOUNT </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">ZLEXCOUNT key min max</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 2.8.9 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(log(N)) with N being the number of elements in the sorted set. </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @read </code> <span class="mr-1 last:hidden"> , </span> <code> @sortedset </code> <span class="mr-1 last:hidden"> , </span> <code> @fast </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> When all the elements in a sorted set are inserted with the same score, in order to force lexicographical ordering, this command returns the number of elements in the sorted set at <code> key </code> with a value between <code> min </code> and <code> max </code> . </p> <p> The <code> min </code> and <code> max </code> arguments have the same meaning as described for <a href="/docs/latest/commands/zrangebylex/"> <code> ZRANGEBYLEX </code> </a> . </p> <p> Note: the command has a complexity of just O(log(N)) because it uses elements ranks (see <a href="/docs/latest/commands/zrank/"> <code> ZRANK </code> </a> ) to get an idea of the range. Because of this there is no need to do a work proportional to the size of the range. </p> <h2 id="examples"> Examples </h2> <div class="bg-slate-900 border-b border-slate-700 rounded-t-xl px-4 py-3 w-full flex"> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10Z"> </path> </svg> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M10 2.5L18.6603 17.5L1.33975 17.5L10 2.5Z"> </path> </svg> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M10 2.5L12.0776 7.9322L17.886 8.22949L13.3617 11.8841L14.8738 17.5L10 14.3264L5.1262 17.5L6.63834 11.8841L2.11403 8.22949L7.92238 7.9322L10 2.5Z"> </path> </svg> </div> <form class="redis-cli overflow-y-auto max-h-80"> <pre tabindex="0">redis&gt; ZADD myzset 0 a 0 b 0 c 0 d 0 e (integer) 5 redis&gt; ZADD myzset 0 f 0 g (integer) 2 redis&gt; ZLEXCOUNT myzset - + (integer) 7 redis&gt; ZLEXCOUNT myzset [b [f (integer) 5 </pre> <div class="prompt" style=""> <span> redis&gt; </span> <input autocomplete="off" name="prompt" spellcheck="false" type="text"/> </div> </form> <h2 id="resp2resp3-reply"> RESP2/RESP3 Reply </h2> <a href="../../develop/reference/protocol-spec#integers"> Integer reply </a> : the number of members in the specified score range. <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/zlexcount/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rc/changelog/2023/august-2023/.html
<section class="prose w-full py-12 max-w-none"> <h1> Redis Cloud changelog (August 2023) </h1> <p class="text-lg -mt-5 mb-10"> New features, enhancements, and other changes added to Redis Cloud during August 2023. </p> <p> This changelog lists new features, enhancements, and other changes added to Redis Cloud during August 2023. </p> <h2 id="new-features"> New features </h2> <h3 id="redis-72-flexible-opt-in"> Redis 7.2 flexible opt-in </h3> <p> You can opt in to Redis 7.2 on <a href="/docs/latest/operate/rc/databases/create-database/create-pro-database-new/"> Flexible subscriptions </a> . Redis 7.2 introduces several changes to existing Redis commands; see the <a href="/docs/latest/operate/rc/changelog/2023/june-2023/#redis-72-breaking-changes"> list of breaking changes </a> published in June's changelog for more details. </p> <h3 id="triggers-and-functions-preview"> Triggers and functions preview </h3> <p> A preview of <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/deprecated-features/triggers-and-functions/"> triggers and functions </a> (previously known as RedisGears) is now available in the following regions: </p> <ul> <li> AWS Asia Pacific - Singapore ( <code> ap-southeast-1 </code> ) </li> <li> GCP Asia Pacific - Tokyo ( <code> asia-northeast1 </code> ) </li> </ul> <p> To use it, <a href="/docs/latest/operate/rc/databases/create-database/create-essentials-database/"> create a fixed subscription </a> in one of these regions. Then, <a href="/docs/latest/operate/rc/databases/create-database/"> create your database </a> and set the database Type to Redis and select Triggers and Functions in the drop-down. Or, set the database Type to Redis Stack to get all of our advanced capabilities. </p> <p> If you'd like to use triggers and functions with a <a href="/docs/latest/operate/rc/databases/create-database/create-pro-database-new/"> Flexible subscription </a> , contact <a href="https://redis.com/company/support/"> support </a> . </p> <p> For more information about triggers and functions, see the <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/deprecated-features/triggers-and-functions/"> triggers and functions documentation </a> . </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> Triggers and functions is discontinued as of <a href="/docs/latest/operate/rc/changelog/may-2024/"> May 2024 </a> . </div> </div> <h3 id="maintenance-windows"> Maintenance windows </h3> <p> You can now <a href="/docs/latest/operate/rc/subscriptions/maintenance/set-maintenance-windows/"> set manual maintenance windows </a> if you want to control when Redis can perform <a href="/docs/latest/operate/rc/subscriptions/maintenance/"> maintenance </a> for a Flexible subscription. </p> <h2 id="known-issues"> Known issues </h2> <h4 id="invalid-acl-rule-causes-failed-state-machine"> Invalid ACL rule causes failed state machine </h4> <p> Applying an invalid ACL rule to a database may cause a failed state machine. If this happens, use the <a href="https://api.redislabs.com/v1/swagger-ui/index.html#/Access%20Control%20List/updateRedisRule"> <code> PUT /v1/acl/redisRules/{aclRedisRuleId} </code> </a> API call to update the rule, and then delete it if necessary. </p> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rc/changelog/2023/august-2023/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/apis/.html
<section class="prose w-full py-12 max-w-none"> <h1> APIs </h1> <p class="text-lg -mt-5 mb-10"> An overview of Redis APIs for developers and operators </p> <p> Redis provides a number of APIs for developers and operators. The following sections provide you easy access to the client API, the several programmability APIs, the RESTFul management APIs and the Kubernetes resource defintions. </p> <h2 id="apis-for-developers"> APIs for Developers </h2> <h3 id="client-api"> Client API </h3> <p> Redis comes with a wide range of commands that help you to develop real-time applications. You can find a complete overview of the Redis commands here: </p> <ul> <li> <a href="/docs/latest/commands/"> Redis commands </a> </li> </ul> <p> As a developer, you will likely use one of our supported client libraries for connecting and executing commands. </p> <ul> <li> <a href="/docs/latest/develop/clients/"> Connect with Redis clients introduction </a> </li> </ul> <h3 id="programmability-apis"> Programmability APIs </h3> <p> The existing Redis commands cover most use cases, but if low latency is a critical requirement, you might need to extend Redis' server-side functionality. </p> <p> Lua scripts have been available since early versions of Redis. With Lua, the script is provided by the client and cached on the server side, which implies the risk that different clients might use a different script version. </p> <ul> <li> <a href="/docs/latest/develop/interact/programmability/lua-api/"> Redis Lua API reference </a> </li> <li> <a href="/docs/latest/develop/interact/programmability/eval-intro/"> Scripting with Lua introduction </a> </li> </ul> <p> The Redis functions feature, which became available in Redis 7, supersedes the use of Lua in prior versions of Redis. The client is still responsible for invoking the execution, but unlike the previous Lua scripts, functions can now be replicated and persisted. </p> <ul> <li> <a href="/docs/latest/develop/interact/programmability/functions-intro/"> Functions and scripting in Redis 7 and beyond </a> </li> </ul> <p> If none of the previous methods fulfills your needs, then you can extend the functionality of Redis with new commands using the Redis Modules API. </p> <ul> <li> <a href="/docs/latest/develop/reference/modules/"> Redis Modules API introduction </a> </li> <li> <a href="/docs/latest/develop/reference/modules/modules-api-ref/"> Redis Modules API reference </a> </li> </ul> <h2 id="apis-for-operators"> APIs for Operators </h2> <h3 id="redis-cloud-api"> Redis Cloud API </h3> <p> Redis Cloud is a fully managed Database as a Service offering and the fastest way to deploy Redis at scale. You can programmatically manage your databases, accounts, access, and credentials using the Redis Cloud REST API. </p> <ul> <li> <a href="/docs/latest/operate/rc/api/"> Redis Cloud REST API introduction </a> </li> <li> <a href="/docs/latest/operate/rc/api/examples/"> Redis Cloud REST API examples </a> </li> <li> <a href="https://api.redislabs.com/v1/swagger-ui.html"> Redis Cloud REST API reference </a> </li> </ul> <h3 id="redis-enterprise-software-api"> Redis Enterprise Software API </h3> <p> If you have installed Redis Enterprise Software, you can automate operations with the Redis Enterprise REST API. </p> <ul> <li> <a href="/docs/latest/operate/rs/references/rest-api/"> Redis Enterprise Software REST API introduction </a> </li> <li> <a href="/docs/latest/operate/rs/references/rest-api/requests/"> Redis Enterprise Software REST API requests </a> </li> <li> <a href="/docs/latest/operate/rs/references/rest-api/objects/"> Redis Enterprise Software REST API objects </a> </li> </ul> <h3 id="redis-enterprise-for-kubernetes-api"> Redis Enterprise for Kubernetes API </h3> <p> If you need to install Redis Enterprise on Kubernetes, then you can use the <a href="/docs/latest/operate/kubernetes/"> Redis Enterprise for Kubernetes Operators </a> . You can find the resource definitions here: </p> <ul> <li> <a href="/docs/latest/operate/kubernetes/reference/redis_enterprise_cluster_api/"> Redis Enterprise Cluster API </a> </li> <li> <a href="/docs/latest/operate/kubernetes/reference/redis_enterprise_database_api/"> Redis Enterprise Database API </a> </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/apis/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/cluster-nodes/.html
<section class="prose w-full py-12"> <h1 class="command-name"> CLUSTER NODES </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">CLUSTER NODES</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 3.0.0 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(N) where N is the total number of Cluster nodes </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @slow </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> Each node in a Redis Cluster has its view of the current cluster configuration, given by the set of known nodes, the state of the connection we have with such nodes, their flags, properties and assigned slots, and so forth. </p> <p> <code> CLUSTER NODES </code> provides all this information, that is, the current cluster configuration of the node we are contacting, in a serialization format which happens to be exactly the same as the one used by Redis Cluster itself in order to store on disk the cluster state (however the on disk cluster state has a few additional info appended at the end). </p> <p> Note that normally clients willing to fetch the map between Cluster hash slots and node addresses should use <a href="/docs/latest/commands/cluster-slots/"> <code> CLUSTER SLOTS </code> </a> instead. <code> CLUSTER NODES </code> , that provides more information, should be used for administrative tasks, debugging, and configuration inspections. It is also used by <code> redis-cli </code> in order to manage a cluster. </p> <h2 id="serialization-format"> Serialization format </h2> <p> The output of the command is just a space-separated CSV string, where each line represents a node in the cluster. The following is an example of output on Redis 7.2.0. </p> <pre tabindex="0"><code>07c37dfeb235213a872192d90877d0cd55635b91 127.0.0.1:30004@31004,hostname4 slave e7d1eecce10fd6bb5eb35b9f99a514335d9ba9ca 0 1426238317239 4 connected 67ed2db8d677e59ec4a4cefb06858cf2a1a89fa1 127.0.0.1:30002@31002,hostname2 master - 0 1426238316232 2 connected 5461-10922 292f8b365bb7edb5e285caf0b7e6ddc7265d2f4f 127.0.0.1:30003@31003,hostname3 master - 0 1426238318243 3 connected 10923-16383 6ec23923021cf3ffec47632106199cb7f496ce01 127.0.0.1:30005@31005,hostname5 slave 67ed2db8d677e59ec4a4cefb06858cf2a1a89fa1 0 1426238316232 5 connected 824fe116063bc5fcf9f4ffd895bc17aee7731ac3 127.0.0.1:30006@31006,hostname6 slave 292f8b365bb7edb5e285caf0b7e6ddc7265d2f4f 0 1426238317741 6 connected e7d1eecce10fd6bb5eb35b9f99a514335d9ba9ca 127.0.0.1:30001@31001,hostname1 myself,master - 0 0 1 connected 0-5460 </code></pre> <p> Each line is composed of the following fields: </p> <pre tabindex="0"><code>&lt;id&gt; &lt;ip:port@cport[,hostname]&gt; &lt;flags&gt; &lt;master&gt; &lt;ping-sent&gt; &lt;pong-recv&gt; &lt;config-epoch&gt; &lt;link-state&gt; &lt;slot&gt; &lt;slot&gt; ... &lt;slot&gt; </code></pre> <p> The meaning of each field is the following: </p> <ol> <li> <code> id </code> : The node ID, a 40-character globally unique string generated when a node is created and never changed again (unless <code> CLUSTER RESET HARD </code> is used). </li> <li> <code> ip:port@cport </code> : The node address that clients should contact to run queries, along with the used cluster bus port. <code> :0@0 </code> can be expected when the address is no longer known for this node ID, hence flagged with <code> noaddr </code> . </li> <li> <code> hostname </code> : A human readable string that can be configured via the <code> cluster-annouce-hostname </code> setting. The max length of the string is 256 characters, excluding the null terminator. The name can contain ASCII alphanumeric characters, '-', and '.' only. </li> <li> <code> flags </code> : A list of comma separated flags: <code> myself </code> , <code> master </code> , <code> slave </code> , <code> fail? </code> , <code> fail </code> , <code> handshake </code> , <code> noaddr </code> , <code> nofailover </code> , <code> noflags </code> . Flags are explained below. </li> <li> <code> master </code> : If the node is a replica, and the primary is known, the primary node ID, otherwise the "-" character. </li> <li> <code> ping-sent </code> : Unix time at which the currently active ping was sent, or zero if there are no pending pings, in milliseconds. </li> <li> <code> pong-recv </code> : Unix time the last pong was received, in milliseconds. </li> <li> <code> config-epoch </code> : The configuration epoch (or version) of the current node (or of the current primary if the node is a replica). Each time there is a failover, a new, unique, monotonically increasing configuration epoch is created. If multiple nodes claim to serve the same hash slots, the one with the higher configuration epoch wins. </li> <li> <code> link-state </code> : The state of the link used for the node-to-node cluster bus. Use this link to communicate with the node. Can be <code> connected </code> or <code> disconnected </code> . </li> <li> <code> slot </code> : A hash slot number or range. Starting from argument number 9, but there may be up to 16384 entries in total (limit never reached). This is the list of hash slots served by this node. If the entry is just a number, it is parsed as such. If it is a range, it is in the form <code> start-end </code> , and means that the node is responsible for all the hash slots from <code> start </code> to <code> end </code> including the start and end values. </li> </ol> <p> Flags are: </p> <ul> <li> <code> myself </code> : The node you are contacting. </li> <li> <code> master </code> : Node is a primary. </li> <li> <code> slave </code> : Node is a replica. </li> <li> <code> fail? </code> : Node is in <code> PFAIL </code> state. Not reachable for the node you are contacting, but still logically reachable (not in <code> FAIL </code> state). </li> <li> <code> fail </code> : Node is in <code> FAIL </code> state. It was not reachable for multiple nodes that promoted the <code> PFAIL </code> state to <code> FAIL </code> . </li> <li> <code> handshake </code> : Untrusted node, we are handshaking. </li> <li> <code> noaddr </code> : No address known for this node. </li> <li> <code> nofailover </code> : Replica will not try to failover. </li> <li> <code> noflags </code> : No flags at all. </li> </ul> <h2 id="notes-on-published-config-epochs"> Notes on published config epochs </h2> <p> Replicas broadcast their primary's config epochs (in order to get an <code> UPDATE </code> message if they are found to be stale), so the real config epoch of the replica (which is meaningless more or less, since they don't serve hash slots) can be only obtained checking the node flagged as <code> myself </code> , which is the entry of the node we are asking to generate <code> CLUSTER NODES </code> output. The other replicas epochs reflect what they publish in heartbeat packets, which is, the configuration epoch of the primaries they are currently replicating. </p> <h2 id="special-slot-entries"> Special slot entries </h2> <p> Normally hash slots associated to a given node are in one of the following formats, as already explained above: </p> <ol> <li> Single number: 3894 </li> <li> Range: 3900-4000 </li> </ol> <p> However node hash slots can be in a special state, used in order to communicate errors after a node restart (mismatch between the keys in the AOF/RDB file, and the node hash slots configuration), or when there is a resharding operation in progress. This two states are <strong> importing </strong> and <strong> migrating </strong> . </p> <p> The meaning of the two states is explained in the Redis Specification, however the gist of the two states is the following: </p> <ul> <li> <strong> Importing </strong> slots are yet not part of the nodes hash slot, there is a migration in progress. The node will accept queries about these slots only if the <code> ASK </code> command is used. </li> <li> <strong> Migrating </strong> slots are assigned to the node, but are being migrated to some other node. The node will accept queries if all the keys in the command exist already, otherwise it will emit what is called an <strong> ASK redirection </strong> , to force new keys creation directly in the importing node. </li> </ul> <p> Importing and migrating slots are emitted in the <code> CLUSTER NODES </code> output as follows: </p> <ul> <li> <strong> Importing slot: </strong> <code> [slot_number-&lt;-importing_from_node_id] </code> </li> <li> <strong> Migrating slot: </strong> <code> [slot_number-&gt;-migrating_to_node_id] </code> </li> </ul> <p> The following are a few examples of importing and migrating slots: </p> <ul> <li> <code> [93-&lt;-292f8b365bb7edb5e285caf0b7e6ddc7265d2f4f] </code> </li> <li> <code> [1002-&lt;-67ed2db8d677e59ec4a4cefb06858cf2a1a89fa1] </code> </li> <li> <code> [77-&gt;-e7d1eecce10fd6bb5eb35b9f99a514335d9ba9ca] </code> </li> <li> <code> [16311-&gt;-292f8b365bb7edb5e285caf0b7e6ddc7265d2f4f] </code> </li> </ul> <p> Note that the format does not have any space, so <code> CLUSTER NODES </code> output format is plain CSV with space as separator even when this special slots are emitted. However a complete parser for the format should be able to handle them. </p> <p> Note that: </p> <ol> <li> Migration and importing slots are only added to the node flagged as <code> myself </code> . This information is local to a node, for its own slots. </li> <li> Importing and migrating slots are provided as <strong> additional info </strong> . If the node has a given hash slot assigned, it will be also a plain number in the list of hash slots, so clients that don't have a clue about hash slots migrations can just skip this special fields. </li> </ol> <p> <strong> A note about the word slave used in this man page and command name </strong> : Starting with Redis 5, if not for backward compatibility, the Redis project no longer uses the word slave. Unfortunately in this command the word slave is part of the protocol, so we'll be able to remove such occurrences only when this API will be naturally deprecated. </p> <h2 id="resp2resp3-reply"> RESP2/RESP3 Reply </h2> <a href="../../develop/reference/protocol-spec#bulk-strings"> Bulk string reply </a> : the serialized cluster configuration. <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/cluster-nodes/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/ft.sugadd/.html
<section class="prose w-full py-12"> <h1 class="command-name"> FT.SUGADD </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">FT.SUGADD key string score [INCR] [PAYLOAD payload] </pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available in: </dt> <dd class="m-0"> <a href="/docs/stack"> Redis Stack </a> / <a href="/docs/interact/search-and-query"> Search 1.0.0 </a> </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) </dd> </dl> <p> Add a suggestion string to an auto-complete suggestion dictionary </p> <p> <a href="#examples"> Examples </a> </p> <h2 id="required-arguments"> Required arguments </h2> <details open=""> <summary> <code> key </code> </summary> <p> is suggestion dictionary key. </p> </details> <details open=""> <summary> <code> string </code> </summary> <p> is suggestion string to index. </p> </details> <details open=""> <summary> <code> score </code> </summary> <p> is floating point number of the suggestion string's weight. </p> </details> <p> The auto-complete suggestion dictionary is disconnected from the index definitions and leaves creating and updating suggestions dictionaries to the user. </p> <h2 id="optional-arguments"> Optional arguments </h2> <details open=""> <summary> <code> INCR </code> </summary> <p> increments the existing entry of the suggestion by the given score, instead of replacing the score. This is useful for updating the dictionary based on user queries in real time. </p> </details> <details open=""> <summary> <code> PAYLOAD {payload} </code> </summary> <p> saves an extra payload with the suggestion, that can be fetched by adding the <code> WITHPAYLOADS </code> argument to <a href="/docs/latest/commands/ft.sugget/"> <code> FT.SUGGET </code> </a> . </p> </details> <h2 id="return"> Return </h2> <p> FT.SUGADD returns an integer reply, which is the current size of the suggestion dictionary. </p> <h2 id="examples"> Examples </h2> <details open=""> <summary> <b> Add a suggestion string to an auto-complete suggestion dictionary </b> </summary> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379&gt; FT.SUGADD sug <span class="s2">"hello world"</span> <span class="m">1</span> </span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">3</span></span></span></code></pre> </div> </details> <h2 id="see-also"> See also </h2> <p> <a href="/docs/latest/commands/ft.sugget/"> <code> FT.SUGGET </code> </a> | <a href="/docs/latest/commands/ft.sugdel/"> <code> FT.SUGDEL </code> </a> | <a href="/docs/latest/commands/ft.suglen/"> <code> FT.SUGLEN </code> </a> </p> <h2 id="related-topics"> Related topics </h2> <p> <a href="/docs/latest/develop/interact/search-and-query/"> RediSearch </a> </p> <br/> <h2> History </h2> <ul> <li> Starting with Redis version 2.0.0: Deprecated <code> PAYLOAD </code> argument </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/ft.sugadd/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rc/databases/connect/.html
<section class="prose w-full py-12 max-w-none"> <h1> Connect to a Redis Cloud database </h1> <p> After you <a href="/docs/latest/operate/rc/databases/create-database/"> create your database </a> , you can connect to it. </p> <p> To connect to the database, you need your username and password. By default, your database is protected by a <a href="/docs/latest/operate/rc/security/access-control/data-access-control/default-user/"> <strong> Default user </strong> </a> called <code> default </code> and a masked <strong> Default user password </strong> . You can see the default user password in the <strong> Security </strong> section of the <strong> Configuration </strong> details for your database. Select the eye icon to show or hide the password. </p> <a href="/docs/latest/images/rc/database-fixed-configuration-security.png" sdata-lightbox="/images/rc/database-fixed-configuration-security.png"> <img alt="The Security section of the Configuration tab of the database details page." src="/docs/latest/images/rc/database-fixed-configuration-security.png" width="75%"/> </a> <p> If you've turned on <a href="/docs/latest/operate/rc/security/access-control/data-access-control/role-based-access-control/"> Role-based access control </a> for your database and <a href="/docs/latest/operate/rc/security/access-control/data-access-control/default-user/#turn-off-default-user"> turned off the default User </a> , use the username and password for your data access role. </p> <p> Once you have the username and password, select <strong> Connect </strong> to open the connection wizard. </p> <a href="/docs/latest/images/rc/connection-wizard-button.png#no-click" sdata-lightbox="/images/rc/connection-wizard-button.png#no-click"> <img alt="Connect button." src="/docs/latest/images/rc/connection-wizard-button.png#no-click"/> </a> <p> The connection wizard provides the following database connection methods: </p> <ul> <li> <p> <a href="#using-redisinsight"> Redis Insight </a> </p> </li> <li> <p> <a href="#using-rediscli"> <code> redis-cli </code> </a> utility </p> </li> <li> <p> <a href="#using-redis-client"> Redis client </a> for your preferred programming language </p> </li> </ul> <a href="/docs/latest/images/rc/connection-wizard.png" sdata-lightbox="/images/rc/connection-wizard.png"> <img alt="The connection wizard." src="/docs/latest/images/rc/connection-wizard.png"/> </a> <h2 id="using-redisinsight"> Redis Insight </h2> <p> <a href="/docs/latest/develop/tools/insight/"> Redis Insight </a> is a free Redis GUI that is available for macOS, Windows, and Linux. </p> <ol> <li> <p> If you haven't downloaded Redis Insight, select <strong> Download </strong> under <strong> Redis Insight </strong> in the Connection wizard to download it. </p> </li> <li> <p> <a href="/docs/latest/develop/tools/insight/"> Install Redis Insight </a> . </p> </li> <li> <p> Once installed, select <strong> Open with Redis Insight </strong> . </p> </li> <li> <p> A pop-up asks if you wish to open the link with Redis Insight. Select <strong> Open Redis Insight </strong> to connect to your database with Redis Insight. </p> </li> </ol> <p> If you get an error when connecting with Redis Insight, <a href="/docs/latest/develop/tools/insight/"> manually connect to your database </a> from Redis Insight. </p> <p> You can use Redis Insight to view your data, run Redis commands, and analyze database performance. See the <a href="/docs/latest/develop/tools/insight/"> Redis Insight docs </a> for more info. </p> <h2 id="using-redis-client"> Redis client </h2> <p> A Redis client is a software library or tool that enables applications to interact with a Redis server. Each client has its own syntax and installation process. For help with a specific client, see the client's documentation. </p> <p> The connection wizard provides code snippets to connect to your database with the following programming languages: </p> <ul> <li> node.js using <a href="/docs/latest/develop/clients/nodejs/"> node-redis </a> </li> <li> .NET using <a href="https://stackexchange.github.io/StackExchange.Redis/"> StackExchange.Redis </a> </li> <li> Python using <a href="/docs/latest/develop/clients/redis-py/"> redis-py </a> </li> <li> Java using <a href="/docs/latest/develop/clients/jedis/"> Jedis </a> </li> </ul> <a href="/docs/latest/images/rc/connection-wizard-clients.png" sdata-lightbox="/images/rc/connection-wizard-clients.png"> <img alt="The connection wizard clients." src="/docs/latest/images/rc/connection-wizard-clients.png"/> </a> <p> If the username and password are not already filled in, replace <code> &lt;username&gt; </code> and <code> &lt;password&gt; </code> with your username and password. </p> <p> See <a href="/docs/latest/develop/clients/"> Clients </a> to learn how to connect with the official Redis clients. </p> <h3 id="using-rediscli"> redis-cli </h3> <p> The <a href="/docs/latest/develop/tools/cli/"> <code> redis-cli </code> </a> utility is installed when you install Redis. It provides a command-line interface that lets you work with your database using core <a href="/docs/latest/commands/"> Redis commands </a> . </p> <p> To run <code> redis-cli </code> , <a href="/docs/latest/operate/oss_and_stack/install/install-stack/"> install Redis Stack </a> on your machine. After it's installed, copy the <code> redis-cli </code> command under <strong> Redis CLI </strong> in the connection wizard and enter it into your terminal. If the username and password are not already filled in, replace <code> &lt;username&gt; </code> and <code> &lt;password&gt; </code> with your username and password. </p> <p> See <a href="/docs/latest/develop/tools/cli/"> Redis CLI </a> to learn how to use <code> redis-cli </code> . </p> <h2 id="more-info"> More info </h2> <ul> <li> <a href="/docs/latest/develop/clients/"> Connect your application </a> </li> <li> <a href="/docs/latest/operate/rc/security/database-security/tls-ssl/#connect-over-tls"> Connect with TLS </a> </li> <li> <a href="/docs/latest/operate/rc/security/access-control/data-access-control/default-user/"> Default user </a> </li> <li> <a href="/docs/latest/operate/rc/security/access-control/data-access-control/role-based-access-control/"> Role-based access control </a> </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rc/databases/connect/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/get/.html
<section class="prose w-full py-12"> <h1 class="command-name"> GET </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">GET key</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 1.0.0 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @read </code> <span class="mr-1 last:hidden"> , </span> <code> @string </code> <span class="mr-1 last:hidden"> , </span> <code> @fast </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> Get the value of <code> key </code> . If the key does not exist the special value <code> nil </code> is returned. An error is returned if the value stored at <code> key </code> is not a string, because <code> GET </code> only handles string values. </p> <h2 id="examples"> Examples </h2> <div class="bg-slate-900 border-b border-slate-700 rounded-t-xl px-4 py-3 w-full flex"> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10Z"> </path> </svg> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M10 2.5L18.6603 17.5L1.33975 17.5L10 2.5Z"> </path> </svg> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M10 2.5L12.0776 7.9322L17.886 8.22949L13.3617 11.8841L14.8738 17.5L10 14.3264L5.1262 17.5L6.63834 11.8841L2.11403 8.22949L7.92238 7.9322L10 2.5Z"> </path> </svg> </div> <form class="redis-cli overflow-y-auto max-h-80"> <pre tabindex="0">redis&gt; GET nonexisting (nil) redis&gt; SET mykey "Hello" "OK" redis&gt; GET mykey "Hello" </pre> <div class="prompt" style=""> <span> redis&gt; </span> <input autocomplete="off" name="prompt" spellcheck="false" type="text"/> </div> </form> <h3 id="code-examples"> Code examples </h3> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="set_and_get-step"> <input checked="" class="radiotab w-0 h-0" data-lang="python" id="Python_set_and_get-step" name="set_and_get-step" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_set_and_get-step" title="Open example"> Python </label> <div aria-labelledby="tab-set_and_get-step" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_set_and_get-step" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for data structure store quickstart pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/get-started/data-store/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">host</span><span class="o">=</span><span class="s2">"localhost"</span><span class="p">,</span> <span class="n">port</span><span class="o">=</span><span class="mi">6379</span><span class="p">,</span> <span class="n">db</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"Process 134"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="c1"># &gt;&gt;&gt; "Process 134"</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_set_and_get-step')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_set_and_get-step" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/string_set_get.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_set_and_get-step" name="set_and_get-step" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_set_and_get-step" title="Open example"> Node.js </label> <div aria-labelledby="tab-set_and_get-step" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_set_and_get-step" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line hl"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="nx">client</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s1">'error'</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=&gt;</span> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">'Redis Client Error'</span><span class="p">,</span> <span class="nx">err</span><span class="p">));</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">().</span><span class="k">catch</span><span class="p">(</span><span class="nx">console</span><span class="p">.</span><span class="nx">error</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s1">'bike:1'</span><span class="p">,</span> <span class="s1">'Process 134'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">value</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s1">'bike:1'</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">value</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="c1">// returns 'Process 134' </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">quit</span><span class="p">();</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_set_and_get-step')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_set_and_get-step" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/string-set-get-example.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_set_and_get-step" name="set_and_get-step" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_set_and_get-step" title="Open example"> Java </label> <div aria-labelledby="tab-set_and_get-step" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_set_and_get-step" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">SetGetExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">status</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"Process 134"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="o">(</span><span class="s">"OK"</span><span class="o">.</span><span class="na">equals</span><span class="o">(</span><span class="n">status</span><span class="o">))</span> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">"Successfully added a bike."</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">value</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="o">(</span><span class="n">value</span> <span class="o">!=</span> <span class="kc">null</span><span class="o">)</span> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">"The name of the bike is: "</span> <span class="o">+</span> <span class="n">value</span> <span class="o">+</span> <span class="s">"."</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_set_and_get-step')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_set_and_get-step" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/SetGetExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_set_and_get-step" name="set_and_get-step" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_set_and_get-step" title="Open example"> Go </label> <div aria-labelledby="tab-set_and_get-step" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_set_and_get-step" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_Set_and_get</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"Process 134"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Err</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="s">"OK"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">value</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Get</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Printf</span><span class="p">(</span><span class="s">"The name of the bike is %s"</span><span class="p">,</span> <span class="nx">value</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_set_and_get-step')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_set_and_get-step" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/set_get_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_set_and_get-step" name="set_and_get-step" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_set_and_get-step" title="Open example"> C# </label> <div aria-labelledby="tab-set_and_get-step" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_set_and_get-step" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">SetGetExample</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">redis</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">redis</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">bool</span> <span class="n">status</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"Process 134"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="n">status</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">"Successfully added a bike."</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">var</span> <span class="k">value</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringGet</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="p">(</span><span class="k">value</span><span class="p">.</span><span class="n">HasValue</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">"The name of the bike is: "</span> <span class="p">+</span> <span class="k">value</span> <span class="p">+</span> <span class="s">"."</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_set_and_get-step')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_set_and_get-step" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/SetGetExample.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <h2 id="resp2-reply"> RESP2 Reply </h2> <p> One of the following: </p> <ul> <li> <a href="../../develop/reference/protocol-spec#bulk-strings"> Bulk string reply </a> : the value of the key. </li> <li> <a href="../../develop/reference/protocol-spec#bulk-strings"> Nil reply </a> : if the key does not exist. </li> </ul> <h2 id="resp3-reply"> RESP3 Reply </h2> <p> One of the following: </p> <ul> <li> <a href="../../develop/reference/protocol-spec#bulk-strings"> Bulk string reply </a> : the value of the key. </li> <li> <a href="../../develop/reference/protocol-spec#nulls"> Null reply </a> : key does not exist. </li> </ul> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/get/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/develop/clients/lettuce/connect/.html
<section class="prose w-full py-12"> <h1> Connect to the server </h1> <p class="text-lg -mt-5 mb-10"> Connect your .NET application to a Redis database </p> <p> Start by creating a connection to your Redis server. There are many ways to achieve this using Lettuce. Here are a few. </p> <h2 id="basic-connection"> Basic connection </h2> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">io.lettuce.core.*</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">io.lettuce.core.api.StatefulRedisConnection</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">io.lettuce.core.api.sync.RedisCommands</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">ConnectBasicTest</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">connectBasic</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisURI</span> <span class="n">uri</span> <span class="o">=</span> <span class="n">RedisURI</span><span class="o">.</span><span class="na">Builder</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">redis</span><span class="o">(</span><span class="s">"localhost"</span><span class="o">,</span> <span class="mi">6379</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">withAuthentication</span><span class="o">(</span><span class="s">"default"</span><span class="o">,</span> <span class="s">"yourPassword"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">build</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisClient</span> <span class="n">client</span> <span class="o">=</span> <span class="n">RedisClient</span><span class="o">.</span><span class="na">create</span><span class="o">(</span><span class="n">uri</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">StatefulRedisConnection</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">String</span><span class="o">&gt;</span> <span class="n">connection</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="na">connect</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisCommands</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">String</span><span class="o">&gt;</span> <span class="n">commands</span> <span class="o">=</span> <span class="n">connection</span><span class="o">.</span><span class="na">sync</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">commands</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"foo"</span><span class="o">,</span> <span class="s">"bar"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">result</span> <span class="o">=</span> <span class="n">commands</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"foo"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">result</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; bar </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">connection</span><span class="o">.</span><span class="na">close</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">client</span><span class="o">.</span><span class="na">shutdown</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <h2 id="asynchronous-connection"> Asynchronous connection </h2> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">org.example</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.*</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.concurrent.ExecutionException</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">io.lettuce.core.*</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">io.lettuce.core.api.async.RedisAsyncCommands</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">io.lettuce.core.api.StatefulRedisConnection</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">Async</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="o">(</span><span class="n">String</span><span class="o">[]</span> <span class="n">args</span><span class="o">)</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisClient</span> <span class="n">redisClient</span> <span class="o">=</span> <span class="n">RedisClient</span><span class="o">.</span><span class="na">create</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">try</span> <span class="o">(</span><span class="n">StatefulRedisConnection</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">String</span><span class="o">&gt;</span> <span class="n">connection</span> <span class="o">=</span> <span class="n">redisClient</span><span class="o">.</span><span class="na">connect</span><span class="o">())</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisAsyncCommands</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">String</span><span class="o">&gt;</span> <span class="n">asyncCommands</span> <span class="o">=</span> <span class="n">connection</span><span class="o">.</span><span class="na">async</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Asynchronously store &amp; retrieve a simple string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">asyncCommands</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"foo"</span><span class="o">,</span> <span class="s">"bar"</span><span class="o">).</span><span class="na">get</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">asyncCommands</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"foo"</span><span class="o">).</span><span class="na">get</span><span class="o">());</span> <span class="c1">// prints bar </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Asynchronously store key-value pairs in a hash directly </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">String</span><span class="o">&gt;</span> <span class="n">hash</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;&gt;();</span> </span></span><span class="line"><span class="cl"> <span class="n">hash</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"name"</span><span class="o">,</span> <span class="s">"John"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">hash</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"surname"</span><span class="o">,</span> <span class="s">"Smith"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">hash</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"company"</span><span class="o">,</span> <span class="s">"Redis"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">hash</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"age"</span><span class="o">,</span> <span class="s">"29"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">asyncCommands</span><span class="o">.</span><span class="na">hset</span><span class="o">(</span><span class="s">"user-session:123"</span><span class="o">,</span> <span class="n">hash</span><span class="o">).</span><span class="na">get</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">asyncCommands</span><span class="o">.</span><span class="na">hgetall</span><span class="o">(</span><span class="s">"user-session:123"</span><span class="o">).</span><span class="na">get</span><span class="o">());</span> </span></span><span class="line"><span class="cl"> <span class="c1">// Prints: {name=John, surname=Smith, company=Redis, age=29} </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">ExecutionException</span> <span class="o">|</span> <span class="n">InterruptedException</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="k">throw</span> <span class="k">new</span> <span class="n">RuntimeException</span><span class="o">(</span><span class="n">e</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> <span class="k">finally</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">redisClient</span><span class="o">.</span><span class="na">shutdown</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <p> Learn more about asynchronous Lettuce API in <a href="https://redis.github.io/lettuce/#asynchronous-api"> the reference guide </a> . </p> <h2 id="reactive-connection"> Reactive connection </h2> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">org.example</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.*</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">io.lettuce.core.*</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">io.lettuce.core.api.reactive.RedisReactiveCommands</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">io.lettuce.core.api.StatefulRedisConnection</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">Main</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="o">(</span><span class="n">String</span><span class="o">[]</span> <span class="n">args</span><span class="o">)</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisClient</span> <span class="n">redisClient</span> <span class="o">=</span> <span class="n">RedisClient</span><span class="o">.</span><span class="na">create</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">try</span> <span class="o">(</span><span class="n">StatefulRedisConnection</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">String</span><span class="o">&gt;</span> <span class="n">connection</span> <span class="o">=</span> <span class="n">redisClient</span><span class="o">.</span><span class="na">connect</span><span class="o">())</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisReactiveCommands</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">String</span><span class="o">&gt;</span> <span class="n">reactiveCommands</span> <span class="o">=</span> <span class="n">connection</span><span class="o">.</span><span class="na">reactive</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Reactively store &amp; retrieve a simple string </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">reactiveCommands</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"foo"</span><span class="o">,</span> <span class="s">"bar"</span><span class="o">).</span><span class="na">block</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="n">reactiveCommands</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"foo"</span><span class="o">).</span><span class="na">doOnNext</span><span class="o">(</span><span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">::</span><span class="n">println</span><span class="o">).</span><span class="na">block</span><span class="o">();</span> <span class="c1">// prints bar </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Reactively store key-value pairs in a hash directly </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">String</span><span class="o">&gt;</span> <span class="n">hash</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;&gt;();</span> </span></span><span class="line"><span class="cl"> <span class="n">hash</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"name"</span><span class="o">,</span> <span class="s">"John"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">hash</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"surname"</span><span class="o">,</span> <span class="s">"Smith"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">hash</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"company"</span><span class="o">,</span> <span class="s">"Redis"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">hash</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"age"</span><span class="o">,</span> <span class="s">"29"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">reactiveCommands</span><span class="o">.</span><span class="na">hset</span><span class="o">(</span><span class="s">"user-session:124"</span><span class="o">,</span> <span class="n">hash</span><span class="o">).</span><span class="na">then</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="n">reactiveCommands</span><span class="o">.</span><span class="na">hgetall</span><span class="o">(</span><span class="s">"user-session:124"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">collectMap</span><span class="o">(</span><span class="n">KeyValue</span><span class="o">::</span><span class="n">getKey</span><span class="o">,</span> <span class="n">KeyValue</span><span class="o">::</span><span class="n">getValue</span><span class="o">).</span><span class="na">doOnNext</span><span class="o">(</span><span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">::</span><span class="n">println</span><span class="o">))</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">block</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="c1">// Prints: {surname=Smith, name=John, company=Redis, age=29} </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> <span class="k">finally</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">redisClient</span><span class="o">.</span><span class="na">shutdown</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <p> Learn more about reactive Lettuce API in <a href="https://redis.github.io/lettuce/#reactive-api"> the reference guide </a> . </p> <h2 id="connect-to-a-redis-cluster"> Connect to a Redis cluster </h2> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">io.lettuce.core.RedisURI</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">io.lettuce.core.cluster.RedisClusterClient</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">io.lettuce.core.cluster.api.StatefulRedisClusterConnection</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">io.lettuce.core.cluster.api.async.RedisAdvancedClusterAsyncCommands</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1">// ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="n">RedisURI</span> <span class="n">redisUri</span> <span class="o">=</span> <span class="n">RedisURI</span><span class="o">.</span><span class="na">Builder</span><span class="o">.</span><span class="na">redis</span><span class="o">(</span><span class="s">"localhost"</span><span class="o">).</span><span class="na">withPassword</span><span class="o">(</span><span class="s">"authentication"</span><span class="o">).</span><span class="na">build</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">RedisClusterClient</span> <span class="n">clusterClient</span> <span class="o">=</span> <span class="n">RedisClusterClient</span><span class="o">.</span><span class="na">create</span><span class="o">(</span><span class="n">redisUri</span><span class="o">);</span> </span></span><span class="line"><span class="cl"><span class="n">StatefulRedisClusterConnection</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">String</span><span class="o">&gt;</span> <span class="n">connection</span> <span class="o">=</span> <span class="n">clusterClient</span><span class="o">.</span><span class="na">connect</span><span class="o">();</span> </span></span><span class="line"><span class="cl"><span class="n">RedisAdvancedClusterAsyncCommands</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">String</span><span class="o">&gt;</span> <span class="n">commands</span> <span class="o">=</span> <span class="n">connection</span><span class="o">.</span><span class="na">async</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1">// ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="n">connection</span><span class="o">.</span><span class="na">close</span><span class="o">();</span> </span></span><span class="line"><span class="cl"><span class="n">clusterClient</span><span class="o">.</span><span class="na">shutdown</span><span class="o">();</span> </span></span></code></pre> </div> <h3 id="tls-connection"> TLS connection </h3> <p> When you deploy your application, use TLS and follow the <a href="/docs/latest/operate/oss_and_stack/management/security/"> Redis security guidelines </a> . </p> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="n">RedisURI</span> <span class="n">redisUri</span> <span class="o">=</span> <span class="n">RedisURI</span><span class="o">.</span><span class="na">Builder</span><span class="o">.</span><span class="na">redis</span><span class="o">(</span><span class="s">"localhost"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">withSsl</span><span class="o">(</span><span class="kc">true</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">withPassword</span><span class="o">(</span><span class="s">"secret!"</span><span class="o">)</span> <span class="c1">// use your Redis password </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="o">.</span><span class="na">build</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">RedisClient</span> <span class="n">client</span> <span class="o">=</span> <span class="n">RedisClient</span><span class="o">.</span><span class="na">create</span><span class="o">(</span><span class="n">redisUri</span><span class="o">);</span> </span></span></code></pre> </div> <h2 id="connection-management-in-lettuce"> Connection Management in Lettuce </h2> <p> Lettuce uses <code> ClientResources </code> for efficient management of shared resources like event loop groups and thread pools. For connection pooling, Lettuce leverages <code> RedisClient </code> or <code> RedisClusterClient </code> , which can handle multiple concurrent connections efficiently. </p> <h2 id="connection-pooling"> Connection pooling </h2> <p> A typical approach with Lettuce is to create a single <code> RedisClient </code> instance and reuse it to establish connections to your Redis server(s). These connections are multiplexed; that is, multiple commands can be run concurrently over a single or a small set of connections, making explicit pooling less practical. See <a href="/docs/latest/develop/clients/pools-and-muxing/"> Connection pools and multiplexing </a> for more information. </p> <p> Lettuce provides pool config to be used with Lettuce asynchronous connection methods. </p> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">org.example</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">io.lettuce.core.RedisClient</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">io.lettuce.core.RedisURI</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">io.lettuce.core.TransactionResult</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">io.lettuce.core.api.StatefulRedisConnection</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">io.lettuce.core.api.async.RedisAsyncCommands</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">io.lettuce.core.codec.StringCodec</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">io.lettuce.core.support.*</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.concurrent.CompletableFuture</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.concurrent.CompletionStage</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">Pool</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="o">(</span><span class="n">String</span><span class="o">[]</span> <span class="n">args</span><span class="o">)</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">RedisClient</span> <span class="n">client</span> <span class="o">=</span> <span class="n">RedisClient</span><span class="o">.</span><span class="na">create</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">host</span> <span class="o">=</span> <span class="s">"localhost"</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> <span class="kt">int</span> <span class="n">port</span> <span class="o">=</span> <span class="mi">6379</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">CompletionStage</span><span class="o">&lt;</span><span class="n">BoundedAsyncPool</span><span class="o">&lt;</span><span class="n">StatefulRedisConnection</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">String</span><span class="o">&gt;&gt;&gt;</span> <span class="n">poolFuture</span> </span></span><span class="line"><span class="cl"> <span class="o">=</span> <span class="n">AsyncConnectionPoolSupport</span><span class="o">.</span><span class="na">createBoundedObjectPoolAsync</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="o">()</span> <span class="o">-&gt;</span> <span class="n">client</span><span class="o">.</span><span class="na">connectAsync</span><span class="o">(</span><span class="n">StringCodec</span><span class="o">.</span><span class="na">UTF8</span><span class="o">,</span> <span class="n">RedisURI</span><span class="o">.</span><span class="na">create</span><span class="o">(</span><span class="n">host</span><span class="o">,</span> <span class="n">port</span><span class="o">)),</span> </span></span><span class="line"><span class="cl"> <span class="n">BoundedPoolConfig</span><span class="o">.</span><span class="na">create</span><span class="o">());</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// await poolFuture initialization to avoid NoSuchElementException: Pool exhausted when starting your application </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">AsyncPool</span><span class="o">&lt;</span><span class="n">StatefulRedisConnection</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">String</span><span class="o">&gt;&gt;</span> <span class="n">pool</span> <span class="o">=</span> <span class="n">poolFuture</span><span class="o">.</span><span class="na">toCompletableFuture</span><span class="o">()</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">join</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// execute work </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">CompletableFuture</span><span class="o">&lt;</span><span class="n">TransactionResult</span><span class="o">&gt;</span> <span class="n">transactionResult</span> <span class="o">=</span> <span class="n">pool</span><span class="o">.</span><span class="na">acquire</span><span class="o">()</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">thenCompose</span><span class="o">(</span><span class="n">connection</span> <span class="o">-&gt;</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisAsyncCommands</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">String</span><span class="o">&gt;</span> <span class="n">async</span> <span class="o">=</span> <span class="n">connection</span><span class="o">.</span><span class="na">async</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">async</span><span class="o">.</span><span class="na">multi</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="n">async</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"key"</span><span class="o">,</span> <span class="s">"value"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">async</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"key2"</span><span class="o">,</span> <span class="s">"value2"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">"Executed commands in pipeline"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="k">return</span> <span class="n">async</span><span class="o">.</span><span class="na">exec</span><span class="o">().</span><span class="na">whenComplete</span><span class="o">((</span><span class="n">s</span><span class="o">,</span> <span class="n">throwable</span><span class="o">)</span> <span class="o">-&gt;</span> <span class="n">pool</span><span class="o">.</span><span class="na">release</span><span class="o">(</span><span class="n">connection</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="o">});</span> </span></span><span class="line"><span class="cl"> <span class="n">transactionResult</span><span class="o">.</span><span class="na">join</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// terminating </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">pool</span><span class="o">.</span><span class="na">closeAsync</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// after pool completion </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">client</span><span class="o">.</span><span class="na">shutdownAsync</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span></code></pre> </div> <p> In this setup, <code> LettuceConnectionFactory </code> is a custom class you would need to implement, adhering to Apache Commons Pool's <code> PooledObjectFactory </code> interface, to manage lifecycle events of pooled <code> StatefulRedisConnection </code> objects. </p> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/clients/lettuce/connect/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/object-idletime/.html
<section class="prose w-full py-12"> <h1 class="command-name"> OBJECT IDLETIME </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">OBJECT IDLETIME key</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 2.2.3 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @keyspace </code> <span class="mr-1 last:hidden"> , </span> <code> @read </code> <span class="mr-1 last:hidden"> , </span> <code> @slow </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> This command returns the time in seconds since the last access to the value stored at <code> &lt;key&gt; </code> . </p> <p> The command is only available when the <code> maxmemory-policy </code> configuration directive is not set to one of the LFU policies. </p> <h2 id="resp2-reply"> RESP2 Reply </h2> One of the following: <a href="../../develop/reference/protocol-spec#integers"> Integer reply </a> : the idle time in seconds. <a href="../../develop/reference/protocol-spec#bulk-strings"> Nil reply </a> : if <em> key </em> doesn't exist. <h2 id="resp3-reply"> RESP3 Reply </h2> One of the following: <a href="../../develop/reference/protocol-spec#integers"> Integer reply </a> : the idle time in seconds. <a href="../../develop/reference/protocol-spec#nulls"> Null reply </a> : if <em> key </em> doesn't exist. <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/object-idletime/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/cms.info/.html
<section class="prose w-full py-12"> <h1 class="command-name"> CMS.INFO </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">CMS.INFO key</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available in: </dt> <dd class="m-0"> <a href="/docs/stack"> Redis Stack </a> / <a href="/docs/data-types/probabilistic"> Bloom 2.0.0 </a> </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) </dd> </dl> <p> Returns width, depth and total count of the sketch. </p> <h3 id="parameters"> Parameters: </h3> <ul> <li> <strong> key </strong> : The name of the sketch. </li> </ul> <h2 id="return"> Return </h2> <p> <a href="/docs/latest/develop/reference/protocol-spec/#arrays"> Array reply </a> with information of the filter. </p> <h2 id="examples"> Examples </h2> <pre tabindex="0"><code>redis&gt; CMS.INFO test 1) width 2) (integer) 2000 3) depth 4) (integer) 7 5) count 6) (integer) 0 </code></pre> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/cms.info/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/acl-dryrun/.html
<section class="prose w-full py-12"> <h1 class="command-name"> ACL DRYRUN </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">ACL DRYRUN username command [arg [arg ...]]</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 7.0.0 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1). </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @admin </code> <span class="mr-1 last:hidden"> , </span> <code> @slow </code> <span class="mr-1 last:hidden"> , </span> <code> @dangerous </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> Simulate the execution of a given command by a given user. This command can be used to test the permissions of a given user without having to enable the user or cause the side effects of running the command. </p> <h2 id="examples"> Examples </h2> <pre tabindex="0"><code>&gt; ACL SETUSER VIRGINIA +SET ~* "OK" &gt; ACL DRYRUN VIRGINIA SET foo bar "OK" &gt; ACL DRYRUN VIRGINIA GET foo "User VIRGINIA has no permissions to run the 'get' command" </code></pre> <h2 id="resp2resp3-reply"> RESP2/RESP3 Reply </h2> <p> Any of the following: </p> <ul> <li> <a href="../../develop/reference/protocol-spec#simple-strings"> Simple string reply </a> : <code> OK </code> on success. </li> <li> <a href="../../develop/reference/protocol-spec#bulk-strings"> Bulk string reply </a> : an error describing why the user can't execute the command. </li> </ul> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/acl-dryrun/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/ft.aggregate.html
<section class="prose w-full py-12"> <h1 class="command-name"> FT.AGGREGATE </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">FT.AGGREGATE index query [VERBATIM] [LOAD count field [field ...]] [TIMEOUT timeout] [ GROUPBY nargs property [property ...] [ REDUCE function nargs arg [arg ...] [AS name] [ REDUCE function nargs arg [arg ...] [AS name] ...]] ...]] [ SORTBY nargs [ property ASC | DESC [ property ASC | DESC ...]] [MAX num] [WITHCOUNT] [ APPLY expression AS name [ APPLY expression AS name ...]] [ LIMIT offset num] [FILTER filter] [ WITHCURSOR [COUNT read_size] [MAXIDLE idle_time]] [ PARAMS nargs name value [ name value ...]] [ADDSCORES] [DIALECT dialect] </pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available in: </dt> <dd class="m-0"> <a href="/docs/stack"> Redis Stack </a> / <a href="/docs/interact/search-and-query"> Search 1.1.0 </a> </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) </dd> </dl> <p> Run a search query on an index, and perform aggregate transformations on the results, extracting statistics etc from them </p> <p> <a href="#examples"> Examples </a> </p> <h2 id="required-arguments"> Required arguments </h2> <details open=""> <summary> <code> index </code> </summary> <p> is index name against which the query is executed. You must first create the index using <a href="/docs/latest/commands/ft.create/"> <code> FT.CREATE </code> </a> . </p> </details> <details open=""> <summary> <code> query </code> </summary> <p> is base filtering query that retrieves the documents. It follows the exact same syntax as the search query, including filters, unions, not, optional, and so on. </p> </details> <h2 id="optional-arguments"> Optional arguments </h2> <details open=""> <summary> <code> VERBATIM </code> </summary> <p> if set, does not try to use stemming for query expansion but searches the query terms verbatim. </p> </details> <details open=""> <summary> <code> LOAD {nargs} {identifier} AS {property} … </code> </summary> <p> loads document attributes from the source document. </p> <ul> <li> <code> identifier </code> is either an attribute name for hashes and JSON or a JSON Path expression for JSON. </li> <li> <code> property </code> is the optional name used in the result. If it is not provided, the <code> identifier </code> is used. This should be avoided. </li> <li> If <code> * </code> is used as <code> nargs </code> , all attributes in a document are loaded. </li> </ul> <p> Attributes needed for aggregations should be stored as <code> SORTABLE </code> , where they are available to the aggregation pipeline with very low latency. <code> LOAD </code> hurts the performance of aggregate queries considerably because every processed record needs to execute the equivalent of <a href="/docs/latest/commands/hmget/"> <code> HMGET </code> </a> against a Redis key, which when executed over millions of keys, amounts to high processing times. </p> <details open=""> <summary> <code> GROUPBY {nargs} {property} </code> </summary> <p> groups the results in the pipeline based on one or more properties. Each group should have at least one <em> reducer </em> , a function that handles the group entries, either counting them, or performing multiple aggregate operations (see below). </p> <details open=""> <summary> <code> REDUCE {func} {nargs} {arg} … [AS {name}] </code> </summary> <p> reduces the matching results in each group into a single record, using a reduction function. For example, <code> COUNT </code> counts the number of records in the group. The reducers can have their own property names using the <code> AS {name} </code> optional argument. If a name is not given, the resulting name will be the name of the reduce function and the group properties. For example, if a name is not given to <code> COUNT_DISTINCT </code> by property <code> @foo </code> , the resulting name will be <code> count_distinct(@foo) </code> . </p> <p> See <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/aggregations#supported-groupby-reducers"> Supported GROUPBY reducers </a> for more details. </p> </details> <details open=""> <summary> <code> SORTBY {nargs} {property} {ASC|DESC} [MAX {num}] </code> </summary> <p> sorts the pipeline up until the point of <code> SORTBY </code> , using a list of properties. </p> <ul> <li> By default, sorting is ascending, but <code> ASC </code> or <code> DESC </code> can be added for each property. </li> <li> <code> nargs </code> is the number of sorting parameters, including <code> ASC </code> and <code> DESC </code> , for example, <code> SORTBY 4 @foo ASC @bar DESC </code> . </li> <li> <code> MAX </code> is used to optimized sorting, by sorting only for the n-largest elements. Although it is not connected to <code> LIMIT </code> , you usually need just <code> SORTBY … MAX </code> for common queries. </li> </ul> <p> Attributes needed for <code> SORTBY </code> should be stored as <code> SORTABLE </code> to be available with very low latency. </p> <p> <strong> Sorting Optimizations </strong> : performance is optimized for sorting operations on <code> DIALECT 4 </code> in different scenarios: </p> <ul> <li> Skip Sorter - applied when there is no sort of any kind. The query can return after it reaches the <code> LIMIT </code> requested results. </li> <li> Partial Range - applied when there is a <code> SORTBY </code> clause over a numeric field, with no filter or filter by the same numeric field, the query iterate on a range large enough to satisfy the <code> LIMIT </code> requested results. </li> <li> Hybrid - applied when there is a <code> SORTBY </code> clause over a numeric field and another non-numeric filter. Some results will get filtered, and the initial range may not be large enough. The iterator is then rewinding with the following ranges, and an additional iteration takes place to collect the <code> LIMIT </code> requested results. </li> <li> No optimization - If there is a sort by score or by non-numeric field, there is no other option but to retrieve all results and compare their values. </li> </ul> <p> <strong> Counts behavior </strong> : optional <code> WITHCOUNT </code> argument returns accurate counts for the query results with sorting. This operation processes all results in order to get an accurate count, being less performant than the optimized option (default behavior on <code> DIALECT 4 </code> ) </p> <details open=""> <summary> <code> APPLY {expr} AS {name} </code> </summary> <p> applies a 1-to-1 transformation on one or more properties and either stores the result as a new property down the pipeline or replaces any property using this transformation. </p> <p> <code> expr </code> is an expression that can be used to perform arithmetic operations on numeric properties, or functions that can be applied on properties depending on their types (see below), or any combination thereof. For example, <code> APPLY "sqrt(@foo)/log(@bar) + 5" AS baz </code> evaluates this expression dynamically for each record in the pipeline and store the result as a new property called <code> baz </code> , which can be referenced by further <code> APPLY </code> / <code> SORTBY </code> / <code> GROUPBY </code> / <code> REDUCE </code> operations down the pipeline. </p> <p> See <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/aggregations/#apply-expressions"> APPLY expressions </a> for details. </p> </details> <details open=""> <summary> <code> LIMIT {offset} {num} </code> </summary> <p> limits the number of results to return just <code> num </code> results starting at index <code> offset </code> (zero-based). It is much more efficient to use <code> SORTBY … MAX </code> if you are interested in just limiting the output of a sort operation. If a key expires during the query, an attempt to <code> load </code> the key's value will return a null array. </p> <p> However, limit can be used to limit results without sorting, or for paging the n-largest results as determined by <code> SORTBY MAX </code> . For example, getting results 50-100 of the top 100 results is most efficiently expressed as <code> SORTBY 1 @foo MAX 100 LIMIT 50 50 </code> . Removing the <code> MAX </code> from <code> SORTBY </code> results in the pipeline sorting <em> all </em> the records and then paging over results 50-100. </p> </details> <details open=""> <summary> <code> FILTER {expr} </code> </summary> <p> filters the results using predicate expressions relating to values in each result. They are applied post query and relate to the current state of the pipeline. </p> </details> <details open=""> <summary> <code> WITHCURSOR {COUNT} {read_size} [MAXIDLE {idle_time}] </code> </summary> <p> Scan part of the results with a quicker alternative than <code> LIMIT </code> . See <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/aggregations#cursor-api"> Cursor API </a> for more details. </p> </details> <details open=""> <summary> <code> TIMEOUT {milliseconds} </code> </summary> <p> if set, overrides the timeout parameter of the module. </p> </details> <details open=""> <summary> <code> PARAMS {nargs} {name} {value} </code> </summary> <p> defines one or more value parameters. Each parameter has a name and a value. </p> <p> You can reference parameters in the <code> query </code> by a <code> $ </code> , followed by the parameter name, for example, <code> $user </code> . Each such reference in the search query to a parameter name is substituted by the corresponding parameter value. For example, with parameter definition <code> PARAMS 4 lon 29.69465 lat 34.95126 </code> , the expression <code> @loc:[$lon $lat 10 km] </code> is evaluated to <code> @loc:[29.69465 34.95126 10 km] </code> . You cannot reference parameters in the query string where concrete values are not allowed, such as in field names, for example, <code> @loc </code> . To use <code> PARAMS </code> , set <code> DIALECT </code> to <code> 2 </code> or greater than <code> 2 </code> . </p> </details> <details open=""> <summary> <code> ADDSCORES </code> </summary> <p> The <code> ADDSCORES </code> option exposes the full-text score values to the aggregation pipeline. You can use <code> @__score </code> in a pipeline as shown in the following example: </p> <p> <code> FT.AGGREGATE idx 'hello' ADDSCORES SORTBY 2 @__score DESC </code> </p> </details> <details open=""> <summary> <code> DIALECT {dialect_version} </code> </summary> <p> selects the dialect version under which to execute the query. If not specified, the query will execute under the default dialect version set during module initial loading or via <a href="/docs/latest/commands/ft.config-set/"> <code> FT.CONFIG SET </code> </a> command. </p> </details> <h2 id="return"> Return </h2> <p> FT.AGGREGATE returns an array reply where each row is an array reply and represents a single aggregate result. The <a href="/docs/latest/develop/reference/protocol-spec#resp-integers"> integer reply </a> at position <code> 1 </code> does not represent a valid value. </p> <h3 id="return-multiple-values"> Return multiple values </h3> <p> See <a href="/docs/latest/commands/ft.search#return-multiple-values/"> Return multiple values </a> in <a href="/docs/latest/commands/ft.search/"> <code> FT.SEARCH </code> </a> The <code> DIALECT </code> can be specified as a parameter in the FT.AGGREGATE command. If it is not specified, the <code> DEFAULT_DIALECT </code> is used, which can be set using <a href="/docs/latest/commands/ft.config-set/"> <code> FT.CONFIG SET </code> </a> or by passing it as an argument to the <code> redisearch </code> module when it is loaded. For example, with the following document and index: </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">127.0.0.1:6379&gt; JSON.SET doc:1 $ <span class="s1">'[{"arr": [1, 2, 3]}, {"val": "hello"}, {"val": "world"}]'</span> </span></span><span class="line"><span class="cl">OK </span></span><span class="line"><span class="cl">127.0.0.1:6379&gt; FT.CREATE idx ON JSON PREFIX <span class="m">1</span> doc: SCHEMA $..arr AS arr NUMERIC $..val AS val TEXT </span></span><span class="line"><span class="cl">OK </span></span></code></pre> </div> <p> Notice the different replies, with and without <code> DIALECT 3 </code> : </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">127.0.0.1:6379&gt; FT.AGGREGATE idx * LOAD <span class="m">2</span> arr val </span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1</span> </span></span><span class="line"><span class="cl">2<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"arr"</span> </span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"[1,2,3]"</span> </span></span><span class="line"><span class="cl"> 3<span class="o">)</span> <span class="s2">"val"</span> </span></span><span class="line"><span class="cl"> 4<span class="o">)</span> <span class="s2">"hello"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl">127.0.0.1:6379&gt; FT.AGGREGATE idx * LOAD <span class="m">2</span> arr val DIALECT <span class="m">3</span> </span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1</span> </span></span><span class="line"><span class="cl">2<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"arr"</span> </span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"[[1,2,3]]"</span> </span></span><span class="line"><span class="cl"> 3<span class="o">)</span> <span class="s2">"val"</span> </span></span><span class="line"><span class="cl"> 4<span class="o">)</span> <span class="s2">"[\"hello\",\"world\"]"</span> </span></span></code></pre> </div> <h2 id="complexity"> Complexity </h2> <p> Non-deterministic. Depends on the query and aggregations performed, but it is usually linear to the number of results returned. </p> <h2 id="examples"> Examples </h2> <details open=""> <summary> <b> Sort page visits by day </b> </summary> <p> Find visits to the page <code> about.html </code> , group them by the day of the visit, count the number of visits, and sort them by day. </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">FT.AGGREGATE idx <span class="s2">"@url:\"about.html\""</span> </span></span><span class="line"><span class="cl"> APPLY <span class="s2">"day(@timestamp)"</span> AS day </span></span><span class="line"><span class="cl"> GROUPBY <span class="m">2</span> @day @country </span></span><span class="line"><span class="cl"> REDUCE count <span class="m">0</span> AS num_visits </span></span><span class="line"><span class="cl"> SORTBY <span class="m">4</span> @day</span></span></code></pre> </div> </details> <details open=""> <summary> <b> Find most books ever published </b> </summary> <p> Find most books ever published in a single year. </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">FT.AGGREGATE books-idx * </span></span><span class="line"><span class="cl"> GROUPBY <span class="m">1</span> @published_year </span></span><span class="line"><span class="cl"> REDUCE COUNT <span class="m">0</span> AS num_published </span></span><span class="line"><span class="cl"> GROUPBY <span class="m">0</span> </span></span><span class="line"><span class="cl"> REDUCE MAX <span class="m">1</span> @num_published AS max_books_published_per_year</span></span></code></pre> </div> </details> <details open=""> <summary> <b> Reduce all results </b> </summary> <p> The last example used <code> GROUPBY 0 </code> . Use <code> GROUPBY 0 </code> to apply a <code> REDUCE </code> function over all results from the last step of an aggregation pipeline -- this works on both the initial query and subsequent <code> GROUPBY </code> operations. </p> <p> Search for libraries within 10 kilometers of the longitude -73.982254 and latitude 40.753181 then annotate them with the distance between their location and those coordinates. </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"> FT.AGGREGATE libraries-idx <span class="s2">"@location:[-73.982254 40.753181 10 km]"</span> </span></span><span class="line"><span class="cl"> LOAD <span class="m">1</span> @location </span></span><span class="line"><span class="cl"> APPLY <span class="s2">"geodistance(@location, -73.982254, 40.753181)"</span></span></span></code></pre> </div> <p> Here, notice the required use of <code> LOAD </code> to pre-load the <code> @location </code> attribute because it is a GEO attribute. </p> <p> Next, count GitHub events by user (actor), to produce the most active users. </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379&gt; FT.AGGREGATE gh <span class="s2">"*"</span> GROUPBY <span class="m">1</span> @actor REDUCE COUNT <span class="m">0</span> AS num SORTBY <span class="m">2</span> @num DESC MAX <span class="m">10</span> </span></span><span class="line"><span class="cl"> 1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">284784</span> </span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"actor"</span> </span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"lombiqbot"</span> </span></span><span class="line"><span class="cl"> 3<span class="o">)</span> <span class="s2">"num"</span> </span></span><span class="line"><span class="cl"> 4<span class="o">)</span> <span class="s2">"22197"</span> </span></span><span class="line"><span class="cl"> 3<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"actor"</span> </span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"codepipeline-test"</span> </span></span><span class="line"><span class="cl"> 3<span class="o">)</span> <span class="s2">"num"</span> </span></span><span class="line"><span class="cl"> 4<span class="o">)</span> <span class="s2">"17746"</span> </span></span><span class="line"><span class="cl"> 4<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"actor"</span> </span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"direwolf-github"</span> </span></span><span class="line"><span class="cl"> 3<span class="o">)</span> <span class="s2">"num"</span> </span></span><span class="line"><span class="cl"> 4<span class="o">)</span> <span class="s2">"10683"</span> </span></span><span class="line"><span class="cl"> 5<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"actor"</span> </span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"ogate"</span> </span></span><span class="line"><span class="cl"> 3<span class="o">)</span> <span class="s2">"num"</span> </span></span><span class="line"><span class="cl"> 4<span class="o">)</span> <span class="s2">"6449"</span> </span></span><span class="line"><span class="cl"> 6<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"actor"</span> </span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"openlocalizationtest"</span> </span></span><span class="line"><span class="cl"> 3<span class="o">)</span> <span class="s2">"num"</span> </span></span><span class="line"><span class="cl"> 4<span class="o">)</span> <span class="s2">"4759"</span> </span></span><span class="line"><span class="cl"> 7<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"actor"</span> </span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"digimatic"</span> </span></span><span class="line"><span class="cl"> 3<span class="o">)</span> <span class="s2">"num"</span> </span></span><span class="line"><span class="cl"> 4<span class="o">)</span> <span class="s2">"3809"</span> </span></span><span class="line"><span class="cl"> 8<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"actor"</span> </span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"gugod"</span> </span></span><span class="line"><span class="cl"> 3<span class="o">)</span> <span class="s2">"num"</span> </span></span><span class="line"><span class="cl"> 4<span class="o">)</span> <span class="s2">"3512"</span> </span></span><span class="line"><span class="cl"> 9<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"actor"</span> </span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"xdzou"</span> </span></span><span class="line"><span class="cl"> 3<span class="o">)</span> <span class="s2">"num"</span> </span></span><span class="line"><span class="cl"> 4<span class="o">)</span> <span class="s2">"3216"</span> </span></span><span class="line"><span class="cl"><span class="o">[</span>10<span class="o">](</span>10<span class="o">))</span> 1<span class="o">)</span> <span class="s2">"actor"</span> </span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"opstest"</span> </span></span><span class="line"><span class="cl"> 3<span class="o">)</span> <span class="s2">"num"</span> </span></span><span class="line"><span class="cl"> 4<span class="o">)</span> <span class="s2">"2863"</span> </span></span><span class="line"><span class="cl">11<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"actor"</span> </span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"jikker"</span> </span></span><span class="line"><span class="cl"> 3<span class="o">)</span> <span class="s2">"num"</span> </span></span><span class="line"><span class="cl"> 4<span class="o">)</span> <span class="s2">"2794"</span> </span></span><span class="line"><span class="cl"><span class="o">(</span>0.59s<span class="o">)</span></span></span></code></pre> </div> </details> <h2 id="see-also"> See also </h2> <p> <a href="/docs/latest/commands/ft.config-set/"> <code> FT.CONFIG SET </code> </a> | <a href="/docs/latest/commands/ft.search/"> <code> FT.SEARCH </code> </a> </p> <h2 id="related-topics"> Related topics </h2> <ul> <li> <a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/aggregations/"> Aggregations </a> </li> <li> <a href="/docs/latest/develop/interact/search-and-query/"> RediSearch </a> </li> </ul> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/ft.aggregate/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </details> </details> </details> </section>
https://redis.io/docs/latest/operate/rc/security/database-security/network-security/.html
<section class="prose w-full py-12 max-w-none"> <h1> Network security </h1> <p> Redis Cloud supports two types of network security: database-level CIDR allow lists and <a href="#virtual-private-clouds"> VPC </a> -wide CIDR allow lists. </p> <p> These features are available in most Redis Cloud configurations, as shown here: </p> <table> <thead> <tr> <th style="text-align:center"> CloudΒ provider </th> <th> VPC peering </th> <th> IP restrictions </th> </tr> </thead> <tbody> <tr> <td style="text-align:center"> AWS </td> <td> Redis Cloud Pro </td> <td> Paid Redis Cloud Essentials and Redis Cloud Pro </td> </tr> <tr> <td style="text-align:center"> Google Cloud </td> <td> Redis Cloud Pro </td> <td> Paid Redis Cloud Essentials and Redis Cloud Pro </td> </tr> <tr> <td style="text-align:center"> Azure </td> <td> Redis Cloud Pro </td> <td> Redis Cloud Pro </td> </tr> </tbody> </table> <h2 id="ip"> IP and subnet restrictions </h2> <p> You can restrict database access to a configurable set of source IP addresses and subnets. This is roughly equivalent to using <a href="https://en.wikipedia.org/wiki/Iptables"> iptables </a> to limit access to a host. </p> <p> To restrict a database to a specific set of source IP addresses or subnets, see <a href="/docs/latest/operate/rc/security/cidr-whitelist/"> Configure CIDR allow list </a> . </p> <h2 id="virtual-private-clouds"> Virtual private clouds </h2> <p> A <a href="https://en.wikipedia.org/wiki/Virtual_private_cloud"> Virtual Private Cloud </a> (VPC) is an isolated set of resources within a <a href="https://en.wikipedia.org/wiki/Cloud_computing#Public_cloud"> public cloud </a> , usually having its own subnets and VLAN. </p> <p> Redis Cloud Pro databases are almost always deployed in a Redis VPC. In most cases, you'll need to create a <a href="/docs/latest/operate/rc/security/vpc-peering/"> VPC peering connection </a> to access these databases. A VPC peering connection allows unrestricted network access between two VPCs. </p> <p> Connection creation and supported features vary by public cloud provider. Learn more about VPC usage for <a href="#vpcs-with-aws"> AWS </a> , <a href="#vpcs-with-google-cloud"> Google Cloud </a> , and <a href="#vpcs-with-azure"> Azure </a> . </p> <h3 id="vpcs-with-aws"> VPCs with AWS </h3> <p> Subscriptions that run on AWS support two VPC options. To ensure that that you can securely connect to your database, you need to <a href="/docs/latest/operate/rc/security/vpc-peering/#aws-vpc-peering"> create a VPC peering connection </a> . </p> <p> If you create a VPC peering connection, you can also <a href="/docs/latest/operate/rc/security/cidr-whitelist/"> configure a CIDR allow list </a> to allow connections only from specific IP address blocks or security groups. </p> <h3 id="vpcs-with-google-cloud"> VPCs with Google Cloud </h3> <p> Subscriptions that run on Google Cloud <em> require </em> a VPC peering connection. See <a href="/docs/latest/operate/rc/security/vpc-peering/#gcp-vpc-peering"> Google Cloud VPC peering </a> to learn how to set up VPC peering for Google Cloud. </p> <h3 id="vpcs-with-azure"> VPCs with Azure </h3> <p> When you request a Redis Cloud Annual subscription, all databases will be deployed in your own Azure VPC. </p> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rc/security/database-security/network-security/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/zmscore/.html
<section class="prose w-full py-12"> <h1 class="command-name"> ZMSCORE </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">ZMSCORE key member [member ...]</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 6.2.0 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(N) where N is the number of members being requested. </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @read </code> <span class="mr-1 last:hidden"> , </span> <code> @sortedset </code> <span class="mr-1 last:hidden"> , </span> <code> @fast </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> Returns the scores associated with the specified <code> members </code> in the sorted set stored at <code> key </code> . </p> <p> For every <code> member </code> that does not exist in the sorted set, a <code> nil </code> value is returned. </p> <h2 id="examples"> Examples </h2> <div class="bg-slate-900 border-b border-slate-700 rounded-t-xl px-4 py-3 w-full flex"> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10Z"> </path> </svg> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M10 2.5L18.6603 17.5L1.33975 17.5L10 2.5Z"> </path> </svg> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M10 2.5L12.0776 7.9322L17.886 8.22949L13.3617 11.8841L14.8738 17.5L10 14.3264L5.1262 17.5L6.63834 11.8841L2.11403 8.22949L7.92238 7.9322L10 2.5Z"> </path> </svg> </div> <form class="redis-cli overflow-y-auto max-h-80"> <pre tabindex="0">redis&gt; ZADD myzset 1 "one" (integer) 1 redis&gt; ZADD myzset 2 "two" (integer) 1 redis&gt; ZMSCORE myzset "one" "two" "nofield" 1) "1" 2) "2" 3) (nil) </pre> <div class="prompt" style=""> <span> redis&gt; </span> <input autocomplete="off" name="prompt" spellcheck="false" type="text"/> </div> </form> <h2 id="resp2-reply"> RESP2 Reply </h2> <p> One of the following: </p> <ul> <li> <a href="../../develop/reference/protocol-spec#bulk-strings"> Nil reply </a> : if the member does not exist in the sorted set. </li> <li> <a href="../../develop/reference/protocol-spec#arrays"> Array reply </a> : a list of <a href="../../develop/reference/protocol-spec#bulk-strings"> Bulk string reply </a> <em> member </em> scores as double-precision floating point numbers. </li> </ul> <h2 id="resp3-reply"> RESP3 Reply </h2> <p> One of the following: </p> <ul> <li> <a href="../../develop/reference/protocol-spec#nulls"> Null reply </a> : if the member does not exist in the sorted set. </li> <li> <a href="../../develop/reference/protocol-spec#arrays"> Array reply </a> : a list of <a href="../../develop/reference/protocol-spec#doubles"> Double reply </a> <em> member </em> scores as double-precision floating point numbers. </li> </ul> <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/zmscore/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rc/security/database-security/.html
<section class="prose w-full py-12 max-w-none"> <h1> Cloud database security </h1> <p> Redis Cloud provides several features to help you secure your databases. These include <a href="/docs/latest/operate/rc/security/access-control/data-access-control/default-user/"> password-based authentication </a> and <a href="/docs/latest/operate/rc/security/access-control/data-access-control/role-based-access-control/"> role-based access control </a> , <a href="/docs/latest/operate/rc/security/database-security/network-security/"> network security </a> , <a href="/docs/latest/operate/rc/security/database-security/tls-ssl/"> TLS </a> , and <a href="/docs/latest/operate/rc/security/encryption-at-rest/"> encryption-at-rest </a> . </p> <h2 id="passwords-users-and-roles"> Passwords, users, and roles </h2> <p> All Redis Cloud databases <a href="/docs/latest/operate/rc/security/access-control/data-access-control/default-user/"> require a password </a> to connect. However, we recommend enabling <a href="/docs/latest/operate/rc/security/access-control/data-access-control/role-based-access-control/"> role-based access control </a> (RBAC) for additional security. With RBAC, you can define all the roles you need, with the appropriate permissions, and assign those roles to your users. </p> <h2 id="network-security"> Network security </h2> <p> Redis Cloud supports two types of network security: <a href="/docs/latest/operate/rc/security/database-security/network-security/#ip"> IP Restrictions </a> and <a href="/docs/latest/operate/rc/security/database-security/network-security/#virtual-private-clouds"> VPCs </a> . We recommend that you employ at least one of these network security options to constrain access to your databases. </p> <h2 id="transport-layer-security-tls"> Transport Layer Security (TLS) </h2> <p> Redis Cloud supports <a href="/docs/latest/operate/rc/security/database-security/tls-ssl/"> Transport Layer Security </a> (TLS) for database connections. TLS, often called "SSL", ensures the privacy of the TCP connection between your application and database. When client authentication is enabled, TLS also ensures that those clients with an authorized key can connect to your Redis databases. </p> <p> We strongly recommend enabling TLS for any application transmitting sensitive data across the wire. </p> <h2 id="disk-encryption"> Disk encryption </h2> <p> Redis Cloud provides encryption for all data stored on disk in Redis databases. See our <a href="/docs/latest/operate/rc/security/encryption-at-rest/"> encryption at rest documentation </a> for specific details. </p> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rc/security/database-security/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/object-refcount/.html
<section class="prose w-full py-12"> <h1 class="command-name"> OBJECT REFCOUNT </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">OBJECT REFCOUNT key</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 2.2.3 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @keyspace </code> <span class="mr-1 last:hidden"> , </span> <code> @read </code> <span class="mr-1 last:hidden"> , </span> <code> @slow </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> This command returns the reference count of the stored at <code> &lt;key&gt; </code> . </p> <h2 id="resp2-reply"> RESP2 Reply </h2> One of the following: <a href="../../develop/reference/protocol-spec#integers"> Integer reply </a> : the number of references. <a href="../../develop/reference/protocol-spec#bulk-strings"> Nil reply </a> : if <em> key </em> doesn't exist. <h2 id="resp3-reply"> RESP3 Reply </h2> One of the following: <a href="../../develop/reference/protocol-spec#integers"> Integer reply </a> : the number of references. <a href="../../develop/reference/protocol-spec#nulls"> Null reply </a> : if <em> key </em> doesn't exist. <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/object-refcount/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/7.4/databases/active-active/develop/.html
<section class="prose w-full py-12 max-w-none"> <h1> Active-Active Redis applications </h1> <p class="text-lg -mt-5 mb-10"> General information to keep in mind while developing applications for an Active-Active database. </p> <p> Developing globally distributed applications can be challenging, as developers have to think about race conditions and complex combinations of events under geo-failovers and cross-region write conflicts. In Redis Enterprise Software (RS), Active-Active databases simplify developing such applications by directly using built-in smarts for handling conflicting writes based on the data type in use. Instead of depending on just simplistic "last-writer-wins" type conflict resolution, geo-distributed Active-Active databases (formerly known as CRDBs) combines techniques defined in CRDT (conflict-free replicated data types) research with Redis types to provide smart and automatic conflict resolution based on the data types intent. </p> <p> An Active-Active database is a globally distributed database that spans multiple Redis Enterprise Software clusters. Each Active-Active database can have many Active-Active database instances that come with added smarts for handling globally distributed writes using the proven <a href="https://en.wikipedia.org/wiki/Conflict-free_replicated_data_type"> CRDT </a> approach. <a href="https://en.wikipedia.org/wiki/Conflict-free_replicated_data_type"> CRDT </a> research describes a set of techniques for creating systems that can handle conflicting writes. CRDBs are powered by Multi-Master Replication (MMR) provides a straightforward and effective way to replicate your data between regions and simplify development of complex applications that can maintain correctness under geo-failovers and concurrent cross-region writes to the same data. </p> <a href="/docs/latest/images/rs/crdbs.png" sdata-lightbox="/images/rs/crdbs.png"> <img alt="Geo-replication world map" src="/docs/latest/images/rs/crdbs.png"/> </a> <p> Active-Active databases replicate data between multiple Redis Enterprise Software clusters. Common uses for Active-Active databases include disaster recovery, geographically redundant applications, and keeping data closer to your user's locations. MMR is always multi-directional amongst the clusters configured in the Active-Active database. For unidirectional replication, please see the Replica Of capabilities in Redis Enterprise Software. </p> <h2 id="example-of-synchronization"> Example of synchronization </h2> <p> In the example below, database writes are concurrent at theΒ point in times t1 and t2 and happen before a sync can communicate the changes. However, writes at times t4 and t6 are not concurrent as a sync happened in between. </p> <table> <thead> <tr> <th style="text-align:right"> <strong> Time </strong> </th> <th style="text-align:center"> <strong> CRDB Instance1 </strong> </th> <th style="text-align:center"> <strong> CRDB Instance2 </strong> </th> </tr> </thead> <tbody> <tr> <td style="text-align:right"> t1 </td> <td style="text-align:center"> SET key1 β€œa” </td> <td style="text-align:center"> </td> </tr> <tr> <td style="text-align:right"> t2 </td> <td style="text-align:center"> </td> <td style="text-align:center"> SET key1 β€œb” </td> </tr> <tr> <td style="text-align:right"> t3 </td> <td style="text-align:center"> β€” Sync β€” </td> <td style="text-align:center"> β€” Sync β€” </td> </tr> <tr> <td style="text-align:right"> t4 </td> <td style="text-align:center"> SET key1 β€œc” </td> <td style="text-align:center"> </td> </tr> <tr> <td style="text-align:right"> t5 </td> <td style="text-align:center"> β€” Sync β€” </td> <td style="text-align:center"> β€” Sync β€” </td> </tr> <tr> <td style="text-align:right"> t6 </td> <td style="text-align:center"> </td> <td style="text-align:center"> SET key1 β€œd” </td> </tr> </tbody> </table> <p> <a href="/docs/latest/operate/rs/7.4/databases/active-active/"> Learn more about synchronization </a> for each supported data type and <a href="/docs/latest/operate/rs/7.4/databases/active-active/develop/develop-for-aa/"> how to develop </a> with them on Redis Enterprise Software. </p> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/databases/active-active/develop/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/oss_and_stack/install/install-stack/binaries/.html
<section class="prose w-full py-12 max-w-none"> <h1> Install Redis Stack from binaries </h1> <p class="text-lg -mt-5 mb-10"> How to install Redis Stack using tarballs </p> <h2 id="start-redis-stack-server"> Start Redis Stack Server </h2> <p> Install the openssl libraries for your platform. For example, on a Debian or Ubuntu instance run: </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo apt install libssl-dev</span></span></code></pre> </div> <p> After untarring or unzipping your redis-stack-server download, you can start Redis Stack Server as follows: </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">/path/to/redis-stack-server/bin/redis-stack-server</span></span></code></pre> </div> <h3 id="add-the-binaries-to-your-path"> Add the binaries to your PATH </h3> <p> You can add the redis-stack-server binaries to your <code> $PATH </code> as follows: </p> <p> Open the file <code> ~/.bashrc </code> or <code> ~/zshrc </code> (depending on your shell), and add the following lines. </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nb">export</span> <span class="nv">PATH</span><span class="o">=</span>/path/to/redis-stack-server/bin:<span class="nv">$PATH</span></span></span></code></pre> </div> <p> If you have an existing Redis installation on your system, then you can choose override those override those PATH variables as before, or you can choose to only add redis-stack-server binary as follows: </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nb">export</span> <span class="nv">PATH</span><span class="o">=</span>/path/to/redis-stack-server/bin/redis-stack-server:<span class="nv">$PATH</span></span></span></code></pre> </div> <p> If you're running redis-stack-server on a mac, please ensure you have openssl installed, via <a href="https://brew.sh/"> homebrew </a> . </p> <p> Now you can start Redis Stack Server as follows: </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis-stack-server</span></span></code></pre> </div> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/oss_and_stack/install/install-stack/binaries/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/reset/.html
<section class="prose w-full py-12"> <h1 class="command-name"> RESET </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">RESET</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 6.2.0 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(1) </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @fast </code> <span class="mr-1 last:hidden"> , </span> <code> @connection </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> This command performs a full reset of the connection's server-side context, mimicking the effect of disconnecting and reconnecting again. </p> <p> When the command is called from a regular client connection, it does the following: </p> <ul> <li> Discards the current <a href="/docs/latest/commands/multi/"> <code> MULTI </code> </a> transaction block, if one exists. </li> <li> Unwatches all keys <a href="/docs/latest/commands/watch/"> <code> WATCH </code> </a> ed by the connection. </li> <li> Disables <a href="/docs/latest/commands/client-tracking/"> <code> CLIENT TRACKING </code> </a> , if in use. </li> <li> Sets the connection to <a href="/docs/latest/commands/readwrite/"> <code> READWRITE </code> </a> mode. </li> <li> Cancels the connection's <a href="/docs/latest/commands/asking/"> <code> ASKING </code> </a> mode, if previously set. </li> <li> Sets <a href="/docs/latest/commands/client-reply/"> <code> CLIENT REPLY </code> </a> to <code> ON </code> . </li> <li> Sets the protocol version to RESP2. </li> <li> <a href="/docs/latest/commands/select/"> <code> SELECT </code> </a> s database 0. </li> <li> Exits <a href="/docs/latest/commands/monitor/"> <code> MONITOR </code> </a> mode, when applicable. </li> <li> Aborts Pub/Sub's subscription state ( <a href="/docs/latest/commands/subscribe/"> <code> SUBSCRIBE </code> </a> and <a href="/docs/latest/commands/psubscribe/"> <code> PSUBSCRIBE </code> </a> ), when appropriate. </li> <li> Deauthenticates the connection, requiring a call <a href="/docs/latest/commands/auth/"> <code> AUTH </code> </a> to reauthenticate when authentication is enabled. </li> <li> Turns off <code> NO-EVICT </code> mode. </li> <li> Turns off <code> NO-TOUCH </code> mode. </li> </ul> <h2 id="resp2resp3-reply"> RESP2/RESP3 Reply </h2> <a href="../../develop/reference/protocol-spec#simple-strings"> Simple string reply </a> : <code> RESET </code> . <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/reset/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisearch/redisearch-2.4-release-notes.html
<section class="prose w-full py-12 max-w-none"> <h1> RediSearch 2.4 release notes </h1> <p class="text-lg -mt-5 mb-10"> Vector Similarity Search (VSS). New query syntax Dialect version 2. Choose between Dialect 1 and Dialect 2 for query parser behavior. Hybrid queries. </p> <h2 id="requirements"> Requirements </h2> <p> RediSearch v2.4.16 requires: </p> <ul> <li> Minimum Redis compatibility version (database): 6.0.0 </li> <li> Minimum Redis Enterprise Software version (cluster): 6.0.0 </li> </ul> <h2 id="v2416-november-2022"> v2.4.16 (November 2022) </h2> <p> This is a maintenance release for RediSearch 2.4 </p> <p> Update urgency: <code> HIGH </code> : There is a critical bug that may affect a subset of users. Upgrade! </p> <p> Details: </p> <ul> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2962"> #2962 </a> Crash upon AOF preload - Use local GC context in periodic callback (MOD-3951) </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2863"> #2863 </a> High CPU Utilization - Change MAX_LEV_DISTANCE to 4 (MOD-3563) </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/3041"> #3041 </a> , <a href="https://github.com/RediSearch/RediSearch/pull/3063"> #3063 </a> , <a href="https://github.com/RediSearch/RediSearch/pull/3051"> #3051 </a> , <a href="https://github.com/RediSearch/RediSearch/pull/3143"> #3143 </a> Several memory leaks (MOD-4121, MOD-4252) </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/3119"> #3119 </a> Crash on intersect iterator GetCriteriaTester (MOD-4200) </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/3128"> #3128 </a> Filter rules must be reevaluated per index per document (MOD-4207) </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/3127"> #3127 </a> Fix assertion failure on wrong result counting, which leads to a crash (MOD-4214) </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/3171"> #3171 </a> Missing implementation of NumericRangeIterator_OnReopen which lead to crash (MOD-4255) </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/3191"> #3191 </a> Wrong query iterator casting which resulted in 100% CPU utilization (MOD-4290) </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/3197"> #3197 </a> Release failed to create temporary indices on the main thread (MOD-4388) </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2981"> #2981 </a> Double freeing in iterators of hybrid queries resulting in crash (MOD-4411) </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/3161"> #3161 </a> Latency used to increase over time when combining INKEYS and wildcard query (MOD-4343) </li> </ul> </li> </ul> <h2 id="v2415-october-2022"> v2.4.15 (October 2022) </h2> <p> This is a maintenance release for RediSearch 2.4. </p> <p> Update urgency: <code> MODERATE </code> : Program an upgrade of the server, but it's not urgent. </p> <p> Details: </p> <ul> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RediSearch/RediSearch/pull/3095"> #3095 </a> Replace order of parsing the parameters and query in the coordinator (MOD-4205) </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/3012"> #3012 </a> Improved efficiency of LLAPI <code> findInfo </code> , which could reduce stability during upgrade in Redis Enterprise (MOD-4197, MOD-4052) </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/3040"> #3040 </a> , <a href="https://github.com/RediSearch/RediSearch/pull/3049"> #3049 </a> Fix for <code> SORTBY </code> numeric field for non-SORTABLE fields on the coordinator (MOD-4115) </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/3050"> #3050 </a> Results from fields from a missing value should come last when combined with <code> SORTBY </code> (MOD-4120) </li> </ul> </li> <li> <p> Improvements: </p> <ul> <li> <a href="https://github.com/RediSearch/RediSearch/pull/3047"> #3047 </a> Add <code> strlen </code> string function to <code> FT.AGGREGATE </code> (MOD-4141) </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/3038"> #3038 </a> Add <code> number_of_uses </code> to <code> FT.INFO </code> for the number of times the index was queried </li> </ul> </li> </ul> <h2 id="v2414-august-2022"> v2.4.14 (August 2022) </h2> <p> This is a maintenance release for RediSearch 2.4. </p> <p> Update urgency: <code> MODERATE </code> : Program an upgrade of the server, but it's not urgent. </p> <p> Details: </p> <ul> <li> <p> Improvements: </p> <ul> <li> <a href="https://github.com/RedisAI/VectorSimilarity/releases/tag/v0.3.2"> Vector similarity v0.3.2 </a> </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2955"> #2955 </a> Add timeout during prefix query (MOD-3949) </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2957"> #2957 </a> Efficient removal from prefix list for cases with many indices </li> </ul> </li> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2937"> #2937 </a> Returning <code> NULL </code> response after encountering an expired document (MOD-3515) </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2962"> #2962 </a> Crash upon AOF preload (MOD-3951) </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2986"> #2986 </a> Memory leak related to schema prefixes </li> </ul> </li> </ul> <h2 id="v2411-july-2022"> v2.4.11 (July 2022) </h2> <p> This is a maintenance release for RediSearch 2.4. </p> <p> Update urgency: <code> MODERATE </code> : Program an upgrade of the server, but it's not urgent. </p> <p> Details: </p> <ul> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2892"> #2892 </a> Combining <code> SORTBY </code> with <code> MAX </code> on <code> FT.SEARCH </code> (which is not supported) caused an inconsistent response and out-of-memory error (MOD-3540, MOD-3644) </li> <li> <a href="https://github.com/RedisAI/VectorSimilarity/releases/tag/v0.3.1"> VecSim v0.3.1 </a> <ul> <li> HNSW indices: reclaim memory upon deletion - HNSW index's data structures now reclaim memory and shrink upon deletion </li> </ul> </li> </ul> </li> <li> <p> Improvements: </p> <ul> <li> <a href="https://github.com/RedisAI/VectorSimilarity/releases/tag/v0.3.1"> VecSim v0.3.1 </a> <ul> <li> HNSW indices: delete procedure is up to 40% faster </li> <li> More accurate memory consumption reporting for HNSW indices </li> </ul> </li> </ul> </li> </ul> <h2 id="v2410-july-2022"> v2.4.10 (July 2022) </h2> <p> This is a maintenance release for RediSearch 2.4. </p> <p> Update urgency: <code> MODERATE </code> : Program an upgrade of the server, but it's not urgent. </p> <p> Details: </p> <ul> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2863"> #2863 </a> Crash due to too high (Levenshtein) <code> DISTANCE </code> in <code> FT.SPELLCHECK </code> . This fix limits the <code> DISTANCE </code> to 4. (MOD-3563) </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2875"> #2875 </a> Not all documents with vector fields were indexed with Auto Tiering (MOD-3584) </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2846"> #2846 </a> Enforce Redis Enterprise memory limit for vector indices </li> </ul> </li> </ul> <h2 id="v249-june-2022"> v2.4.9 (June 2022) </h2> <p> This is a maintenance release for RediSearch 2.4. </p> <p> Update urgency: <code> MODERATE </code> : Program an upgrade of the server, but it's not urgent. </p> <p> Details: </p> <ul> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2837"> #2837 </a> , <a href="https://github.com/RediSearch/RediSearch/issues/2836"> #2836 </a> Crash on <code> FT.AGGREGATE </code> "... APPLY '-INF % -1'..." </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2814"> #2814 </a> <code> FT.EXPLAIN </code> without parameters causes a crash </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2790"> #2790 </a> Incorrect <code> num_terms </code> value in <code> FT.INFO </code> after a term is deleted from all the docs (garbage collection) </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2804"> #2804 </a> Freeze when <code> OFFSET </code> + <code> LIMIT </code> was greater than <code> maxSearchResults </code> (config) </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2791"> #2791 </a> Add <code> BlockedClientMeasureTime </code> to coordinator for more accurate performance stats </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2802"> #2802 </a> Tagged parts of keys (curly brackets <code> {} </code> ) are now returned by <code> FT.SEARCH </code> </li> </ul> </li> <li> <p> Improvements: </p> <ul> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2806"> #2806 </a> Do not load the JSON API when RediSearch is initialized as a library </li> </ul> </li> <li> <p> Minor breaking change: </p> <ul> <li> As pointed out above, <a href="https://github.com/RediSearch/RediSearch/pull/2802"> #2802 </a> is a bug fix. However, if your application relies on RediSearch incorrectly trimming the tagged part of a key (using <code> {} </code> ), this could break your application. This only applies to users who are using RediSearch in clustered databases. </li> </ul> </li> </ul> <h2 id="v248-may-2022"> v2.4.8 (May 2022) </h2> <p> This is a maintenance release for RediSearch 2.4. </p> <p> Update urgency: <code> MODERATE </code> : Program an upgrade of the server, but it's not urgent. However, if you're using Vector Similarity (introduced in RediSearch 2.4), there are some critical bugs that may affect a subset of users. In this case, you should upgrade. </p> <p> Details: </p> <ul> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2739"> #2739 </a> Memory leak in coordinator related to Vector Similarity (MOD-3023) </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2736"> #2736 </a> , <a href="https://github.com/RediSearch/RediSearch/pull/2782"> #2782 </a> Memory allocation restrictions for Vector Similarity indices (causing OOM) (MOD-3195) </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2755"> #2755 </a> Compare the entire vector field name instead of a prefix when creating a new vector index </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2780"> #2780 </a> Initialize all variables in <code> EvalContext </code> (which might have led to crashes in clustered databases) </li> </ul> </li> <li> <p> Improvements: </p> <ul> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2740"> #2740 </a> Performance optimization for hybrid vector queries </li> </ul> </li> </ul> <h2 id="v246-may-2022"> v2.4.6 (May 2022) </h2> <p> This is a maintenance release for RediSearch 2.4. </p> <p> Update urgency: <code> MODERATE </code> : Program an upgrade of the server, but it's not urgent. </p> <p> Details: </p> <ul> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2716"> #2716 </a> Removed assert statement that could cause crashes with replica of (MOD-3008, MOD-3012) </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2734"> #2734 </a> <code> ON_TIMEOUT RETURN </code> policy fix: return results obtained until timeout rather than discarding them </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2714"> #2714 </a> Memory leak on non-TLS setup in coordinator </li> </ul> </li> </ul> <h2 id="v245-april-2022"> v2.4.5 (April 2022) </h2> <p> This is a maintenance release for RediSearch 2.4. </p> <p> Update urgency: <code> MODERATE </code> : Program an upgrade of the server, but it's not urgent. </p> <p> Details: </p> <ul> <li> <p> Bug fixes: </p> <ul> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2702"> #2702 </a> <code> INKEYS </code> combined with Vector Similarity caused server unresponsiveness (MOD-2952) </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2705"> #2705 </a> Incorrect results when deleting a document that was skipped at index time </li> <li> <a href="https://github.com/RediSearch/RediSearch/issues/2698"> #2698 </a> Synonyms in Chinese </li> </ul> </li> <li> <p> Improvements: </p> <ul> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2694"> #2694 </a> Performance: In a <code> TEXT </code> field, skip term iterator if term does not appear in requested field </li> </ul> </li> </ul> <h2 id="v243-march-2022"> v2.4.3 (March 2022) </h2> <p> This is the General Availability release of RediSearch 2.4. </p> <h3 id="headlines"> Headlines </h3> <p> RediSearch 2.4 introduces a new capability, Vector Similarity Search (VSS), which allows indexing and querying vector data stored (as BLOBs) in Redis hashes. </p> <p> It also introduces a new query syntax to address query parser inconsistencies found in previous versions of RediSearch. Users can now choose between Dialect version 1 (to keep existing query parser behavior) or Dialect version 2 (to switch to the updated behavior). </p> <p> All VSS queries or any query using the <code> PARAMS </code> option must use Dialect version 2. </p> <h3 id="whats-new-in-24"> What's new in 2.4 </h3> <ul> <li> <p> <code> FT.CREATE </code> is extended to support the creation of 2 popular types of vector indexes: </p> <ul> <li> <p> <strong> FLAT Index </strong> </p> <p> This type of index is used when the recall is more important than the speed of query execution. A query vector will be compared to all vectors in a flat index. The search results will return the exact top k nearest neighbors to the query vector. </p> </li> <li> <p> <strong> Hierarchical Navigable Small World (HNSW) Index </strong> </p> <p> This index is a modified implementation of the library written by the author of this influential <a href="https://arxiv.org/abs/1603.09320"> academic paper </a> . An HNSW vector index is used when the speed of query execution is preferred over recall. The results returned are approximate nearest neighbors (ANNs). </p> <p> You can try out different HNSW index parameters ( <code> M </code> , <code> EFCONSTRUCTION </code> , <code> EFRUNTIME </code> ) to improve the β€œrecall versus speed” balance. </p> </li> </ul> </li> <li> <p> Use <code> FT.SEARCH </code> to retrieve the top K hashes with the most similar vectors to a given query vector. </p> </li> <li> <p> Hybrid queries in <code> FT.SEARCH </code> : </p> <p> Use hybrid queries to retrieve Redis hashes that match a combination of vector and non-vector search criteria. Non-vector search criteria can include expressions combining <code> NUMERIC </code> , <code> TEXT </code> , <code> TAG </code> , and <code> GEO </code> fields. </p> <p> Hybrid queries are often used in modern ecommerce search applications featuring β€œvisual” similarity plus metadata similarity. For example, you can use a single hybrid query to find products that are visually similar to a given image within a price range and/or geo-location. </p> </li> <li> <p> Use <a href="/docs/latest/commands/ft.config-set"> <code> FT.CONFIG SET </code> </a> to set <code> DEFAULT_DIALECT </code> at the module level. By default, <code> DEFAULT_DIALECT </code> is set to 1. </p> </li> <li> <p> Override <code> DIALECT </code> : </p> <p> It is possible to override the module-level dialect for a specific command at runtime. You can specify the dialect when executing any of the following commands: </p> <ul> <li> <p> <a href="/docs/latest/commands/ft.search"> <code> FT.SEARCH </code> </a> </p> </li> <li> <p> <a href="/docs/latest/commands/ft.aggregate"> <code> FT.AGGREGATE </code> </a> </p> </li> <li> <p> <a href="/docs/latest/commands/ft.explain"> <code> FT.EXPLAIN </code> </a> </p> </li> <li> <p> <a href="/docs/latest/commands/ft.explaincli"> <code> FT.EXPLAINCLI </code> </a> </p> </li> <li> <p> <a href="/docs/latest/commands/ft.spellcheck"> <code> FT.SPELLCHECK </code> </a> </p> </li> </ul> <p> If you do not specify dialect when running any of these commands, they will use the default module-level dialect value. </p> </li> </ul> <h3 id="details"> Details </h3> <ul> <li> <p> Features: </p> <ul> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2671"> #2671 </a> Add Dialect support </li> </ul> </li> <li> <p> Performance enhancements (since 2.4-RC1): </p> <ul> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2647"> #2647 </a> Normalize vector once for ad-hoc flat search </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2638"> #2638 </a> Optimized hybrid query when no scores are required </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2653"> #2653 </a> Updating specific field load optimization rule </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2670"> #2670 </a> Use <code> REDISMODULE_EVENT_SHUTDOWN </code> to clear resources </li> </ul> </li> <li> <p> Security and privacy (since 2.4-RC1): </p> <ul> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2584"> #2584 </a> Fix MOD-2086, added support for TLS passphrase </li> </ul> </li> <li> <p> Bug fixes (since 2.4-RC1): </p> <ul> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2651"> #2651 </a> Fix client freeze on docs expire during query </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2641"> #2641 </a> Memory leak in the coordinator </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2645"> #2645 </a> Ignore NULL value on ingest </li> <li> <a href="https://github.com/RediSearch/RediSearch/pull/2654"> #2654 </a> VecSim hybrid query - return empty iterator for invalid intersection child iterator </li> </ul> </li> </ul> <h3 id="introducing-dialect"> Introducing DIALECT </h3> <p> RediSearch 2.4.3 introduces a new query syntax to address query parser inconsistencies found in previous versions of RediSearch. Users can now choose between: </p> <ul> <li> <p> Dialect version 1 (to keep the query dialect as in RediSearch 2.2) </p> </li> <li> <p> Dialect version 2 (to use the updated dialect) </p> </li> </ul> <p> Existing RediSearch 2.2 users will not have to modify their queries since the default dialect is 1. However, all RediSearch users should gradually update their queries to use dialect version 2. </p> <h4 id="background"> Background </h4> <p> Under certain conditions, some query parsing rules did not behave as originally intended. Queries containing the following operators could return unexpected results: </p> <ul> <li> <code> AND </code> </li> <li> quotes, ~, -, and % (exact, optional, negation, fuzzy) </li> <li> <code> OR </code> </li> </ul> <p> To minimize the impact on existing, unaffected RediSearch users, a DIALECT setting was introduced to allow: </p> <ul> <li> <p> Existing queries to run without any modification (DIALECT 1) </p> </li> <li> <p> New queries to benefit from the updated query-parsing behavior (DIALECT 2) </p> </li> </ul> <h4 id="examples-of-impacted-queries"> Examples of impacted queries </h4> <p> Your existing queries may behave differently under different DIALECT versions, if they fall into any of the following categories: </p> <ul> <li> <p> Your query has a field modifier followed by multiple words. </p> <p> Consider this simple query <nobr> <code> @name:James Brown </code> </nobr> . </p> <p> The field modifier <code> @name </code> is followed by 2 words: <code> James </code> and <code> Brown </code> . </p> <p> With DIALECT 1, the parser interprets this query as "find <code> James Brown </code> in the <code> @name </code> field." </p> <p> With DIALECT 2, the parser interprets it as "find <code> James </code> in the <code> @name </code> field AND <code> Brown </code> in ANY text field." In other words, the query parser interprets it as <nobr> <code> (@name:James) Brown </code> </nobr> . </p> <p> With DIALECT 2, you could achieve the default behavior from DIALECT 1 by updating your query to <nobr> <code> @name:(James Brown) </code> </nobr> . </p> </li> <li> <p> Your query uses quotes, ~, -, % (exact, optional, negation, fuzzy). </p> <p> Consider a simple query with negation <nobr> <code> -hello world </code> </nobr> . </p> <p> With DIALECT 1, the parser interprets this query as "find values in any field that does not contain <code> hello </code> AND does not contain <code> world </code> ." This is the equivalent of <nobr> <code> -(hello world) </code> </nobr> or <nobr> <code> -hello -world </code> </nobr> . </p> <p> With DIALECT 2, the parser interprets it as <code> -hello </code> AND <code> world </code> , so only <code> hello </code> is negated. </p> <p> With DIALECT 2, you could achieve the default behavior from dialect 1 by updating your query to <nobr> <code> -(hello world) </code> </nobr> . </p> </li> </ul> <p> Another example that illustrates the differences in parser behavior is <code> hello world | "goodbye" moon </code> : </p> <ul> <li> <p> With DIALECT 1, the parser interprets this query as searching for <code> (hello world | "goodbye") moon </code> </p> </li> <li> <p> With DIALECT 2, the parser interprets it as searching for either <code> hello world </code> OR <code> "goodbye" moon </code> . </p> </li> </ul> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> This is the first GA version of 2.4. The version inside Redis will be 2.4.3 in semantic versioning. Since the version of a module in Redis is numeric, we could not add a GA flag. </div> </div> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisearch/redisearch-2.4-release-notes/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/groupbitmap.html
<section class="prose w-full py-12"> <h1> Commands </h1> </section>
https://redis.io/docs/latest/develop/data-types/json/path/.html
<section class="prose w-full py-12"> <h1> Path </h1> <p class="text-lg -mt-5 mb-10"> Access specific elements within a JSON document </p> <p> Paths let you access specific elements within a JSON document. Since no standard for JSON path syntax exists, Redis JSON implements its own. JSON's syntax is based on common best practices and intentionally resembles <a href="http://goessner.net/articles/JsonPath/"> JSONPath </a> . </p> <p> JSON supports two query syntaxes: <a href="#jsonpath-syntax"> JSONPath syntax </a> and the <a href="#legacy-path-syntax"> legacy path syntax </a> from the first version of JSON. </p> <p> JSON knows which syntax to use depending on the first character of the path query. If the query starts with the character <code> $ </code> , it uses JSONPath syntax. Otherwise, it defaults to the legacy path syntax. </p> <p> The returned value is a JSON string with a top-level array of JSON serialized strings. And if multi-paths are used, the return value is a JSON string with a top-level object with values that are arrays of serialized JSON values. </p> <h2 id="jsonpath-support"> JSONPath support </h2> <p> RedisJSON v2.0 introduced <a href="http://goessner.net/articles/JsonPath/"> JSONPath </a> support. It follows the syntax described by Goessner in his <a href="http://goessner.net/articles/JsonPath/"> article </a> . </p> <p> A JSONPath query can resolve to several locations in a JSON document. In this case, the JSON commands apply the operation to every possible location. This is a major improvement over <a href="#legacy-path-syntax"> legacy path </a> queries, which only operate on the first path. </p> <p> Notice that the structure of the command response often differs when using JSONPath. See the <a href="/docs/latest/commands/?group=json"> Commands </a> page for more details. </p> <p> The new syntax supports bracket notation, which allows the use of special characters like colon ":" or whitespace in key names. </p> <p> If you want to include double quotes in a query from the CLI, enclose the JSONPath within single quotes. For example: </p> <div class="highlight"> <pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">JSON.GET store <span class="s1">'$.inventory["mountain_bikes"]'</span> </span></span></code></pre> </div> <h2 id="jsonpath-syntax"> JSONPath syntax </h2> <p> The following JSONPath syntax table was adapted from Goessner's <a href="https://goessner.net/articles/JsonPath/index.html#e2"> path syntax comparison </a> . </p> <table> <thead> <tr> <th> SyntaxΒ element </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> $ </td> <td> The root (outermost JSON element), starts the path. </td> </tr> <tr> <td> . or [] </td> <td> Selects a child element. </td> </tr> <tr> <td> .. </td> <td> Recursively descends through the JSON document. </td> </tr> <tr> <td> * </td> <td> Wildcard, returns all elements. </td> </tr> <tr> <td> [] </td> <td> Subscript operator, accesses an array element. </td> </tr> <tr> <td> [,] </td> <td> Union, selects multiple elements. </td> </tr> <tr> <td> [start:end:step] </td> <td> Array slice where <em> start </em> , <em> end </em> , and <em> step </em> are index values. You can omit values from the slice (for example, <code> [3:] </code> , <code> [:8:2] </code> ) to use the default values: <em> start </em> defaults to the first index, <em> end </em> defaults to the last index, and <em> step </em> defaults to <code> 1 </code> . Use <code> [*] </code> or <code> [:] </code> to select all elements. </td> </tr> <tr> <td> ?() </td> <td> Filters a JSON object or array. Supports comparison operators <nobr> ( <code> == </code> , <code> != </code> , <code> &lt; </code> , <code> &lt;= </code> , <code> &gt; </code> , <code> &gt;= </code> , <code> =~ </code> ) </nobr> , logical operators <nobr> ( <code> &amp;&amp; </code> , <code> || </code> ) </nobr> , and parenthesis <nobr> ( <code> ( </code> , <code> ) </code> ) </nobr> . </td> </tr> <tr> <td> () </td> <td> Script expression. </td> </tr> <tr> <td> @ </td> <td> The current element, used in filter or script expressions. </td> </tr> </tbody> </table> <h2 id="jsonpath-examples"> JSONPath examples </h2> <p> The following JSONPath examples use this JSON document, which stores details about items in a store's inventory: </p> <div class="highlight"> <pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"inventory"</span><span class="p">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"mountain_bikes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"id"</span><span class="p">:</span> <span class="s2">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"model"</span><span class="p">:</span> <span class="s2">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"description"</span><span class="p">:</span> <span class="s2">"This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there\u2019s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="nt">"material"</span><span class="p">:</span> <span class="s2">"carbon"</span><span class="p">,</span> <span class="nt">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="nt">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"id"</span><span class="p">:</span> <span class="s2">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"model"</span><span class="p">:</span> <span class="s2">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"description"</span><span class="p">:</span> <span class="s2">"Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and tear. All in all it's an impressive package for the price, making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="nt">"material"</span><span class="p">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> <span class="nt">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="nt">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"white"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"id"</span><span class="p">:</span> <span class="s2">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"model"</span><span class="p">:</span> <span class="s2">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"description"</span><span class="p">:</span> <span class="s2">"This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="nt">"material"</span><span class="p">:</span> <span class="s2">"alloy"</span><span class="p">,</span> <span class="nt">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="nt">"commuter_bikes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"id"</span><span class="p">:</span> <span class="s2">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"model"</span><span class="p">:</span> <span class="s2">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"description"</span><span class="p">:</span> <span class="s2">"This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, this is a bike which doesn\u2019t break the bank and delivers craved performance. It\u2019s for the rider who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="nt">"material"</span><span class="p">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> <span class="nt">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="nt">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nt">"id"</span><span class="p">:</span> <span class="s2">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"model"</span><span class="p">:</span> <span class="s2">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"description"</span><span class="p">:</span> <span class="s2">"A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nt">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="nt">"material"</span><span class="p">:</span> <span class="s2">"alloy"</span><span class="p">,</span> <span class="nt">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <p> First, create the JSON document in your database: </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="json_tutorial-stepset_bikes"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_json_tutorial-stepset_bikes" name="json_tutorial-stepset_bikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_json_tutorial-stepset_bikes" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-json_tutorial-stepset_bikes" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_json_tutorial-stepset_bikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">JSON.SET bikes:inventory $ '{ "inventory": { "mountain_bikes": [ { "id": "bike:1", "model": "Phoebe", "description": "This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there\'s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership.", "price": 1920, "specs": {"material": "carbon", "weight": 13.1}, "colors": ["black", "silver"] }, { "id": "bike:2", "model": "Quaoar", "description": "Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we\'ve ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and tear. All in all it\'s an impressive package for the price, making it very competitive.", "price": 2072, "specs": {"material": "aluminium", "weight": 7.9}, "colors": ["black", "white"] }, { "id": "bike:3", "model": "Weywot", "description": "This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you\'re after a budget option, this is one of the best bikes you could get.", "price": 3264, "specs": {"material": "alloy", "weight": 13.8} } ], "commuter_bikes": [ { "id": "bike:4", "model": "Salacia", "description": "This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano\'s, this is a bike which doesn\'t break the bank and delivers craved performance. It\'s for the rider who wants both efficiency and capability.", "price": 1475, "specs": {"material": "aluminium", "weight": 16.6}, "colors": ["black", "silver"] }, { "id": "bike:5", "model": "Mimas", "description": "A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price.", "price": 3941, "specs": {"material": "alloy", "weight": 11.6} } ] }}'</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_json_tutorial-stepset_bikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_json_tutorial-stepset_bikes" name="json_tutorial-stepset_bikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_json_tutorial-stepset_bikes" title="Open example"> Python </label> <div aria-labelledby="tab-json_tutorial-stepset_bikes" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_json_tutorial-stepset_bikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for JSON doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/json/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s1">'"Hyperion"'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Hyperion"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['string']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">strlen</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [10]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">strappend</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s1">'" (Enduro bikes)"'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 27</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Hyperion"" (Enduro bikes)"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [2.5]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1.75]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"Deimos"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"crashes"</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span> <span class="kc">None</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['["Deimos", { "crashes": 0 }, null]']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$[1].crashes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['0']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$.[-1]"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Deimos', {'crashes': 0}]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrappend</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s2">"Norem"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Norem']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrinsert</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">,</span> <span class="s2">"Royce"</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [4]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Norem', 'Prickett', 'Royce', 'Castilla']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrtrim</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res21</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res22</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res22</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Prickett']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res23</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrpop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res23</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Prickett"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res24</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrpop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res24</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [None]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res25</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Deimos"</span><span class="p">,</span> <span class="s2">"brand"</span><span class="p">:</span> <span class="s2">"Ergonom"</span><span class="p">,</span> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">4972</span><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res25</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res26</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">objlen</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res26</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [3]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">objkeys</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['model', 'brand', 'price']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">inventory_json</span> <span class="o">=</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"inventory"</span><span class="p">:</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"mountain_bikes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line hl"><span class="cl"> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:1"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Phoebe"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This is a mid-travel trail slayer that is a fantastic "</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"gives plenty of gear range to tackle hills and there</span><span class="se">\u2019</span><span class="s2">s room for "</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"mudguards and a rack too. This is the bike for the rider who wants "</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"carbon"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line hl"><span class="cl"> <span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:2"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Quaoar"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"Redesigned for the 2020 model year, this bike "</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"impressed our testers and is the best all-around trail bike we've "</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"ever tested. The Shimano gear system effectively does away with an "</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"external cassette, so is super low maintenance in terms of wear "</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"and tear. All in all it's an impressive package for the price, "</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"white"</span><span class="p">],</span> </span></span><span class="line hl"><span class="cl"> <span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:3"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Weywot"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This bike gives kids aged six years and older "</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"a durable and uberlight mountain bike for their first experience "</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"on tracks and easy cruising through forests and fields. A set of "</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"ability. If you're after a budget option, this is one of the best "</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"alloy"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="p">],</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"commuter_bikes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line hl"><span class="cl"> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:4"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Salacia"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This bike is a great option for anyone who just "</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"wants a bike to get about on With a slick-shifting Claris gears "</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"from Shimano</span><span class="se">\u2019</span><span class="s2">s, this is a bike which doesn</span><span class="se">\u2019</span><span class="s2">t break the "</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"bank and delivers craved performance. It</span><span class="se">\u2019</span><span class="s2">s for the rider "</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line hl"><span class="cl"> <span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:5"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Mimas"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"A real joy to ride, this bike got very high "</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"scores in last years Bike of the year report. The carefully "</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"Vittoria Zaffiro tires give balance and grip.It includes "</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"conveniently placed thumb throttle. Put it all together and you "</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"alloy"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="p">],</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"><span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="n">inventory_json</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; [[{'id': 'bike:1', 'model': 'Phoebe',</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 'description': 'This is a mid-travel trail slayer...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[*].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s1">'$.inventory["mountain_bikes"][*].model'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..mountain_bikes[*].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot', 'Salacia', 'Mimas']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..mountain_bikes[0:2].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; [{'id': 'bike:2', 'model': 'Quaoar',</span> </span></span><span class="line"><span class="cl"><span class="c1"># 'description': "Redesigned for the 2020 model year...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[?(@.specs.material == 'alloy')].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Weywot', 'Mimas']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Quaoar', 'Weywot', 'Salacia', 'Mimas']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Quaoar', 'Weywot']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1920, 2072, 3264, 1475, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1820, 1972, 3164, 1375, 3841]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1920, 2072, 3264, 1475, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> <span class="mi">1500</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1500, 2072, 3264, 1500, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrappend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s2">"pink"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [3, 3]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[*].colors"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="n">res21</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['black', 'silver', 'pink'], ['black', 'white'], ['black', 'silver', 'pink']]</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_json_tutorial-stepset_bikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_json_tutorial-stepset_bikes" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_json.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_json_tutorial-stepset_bikes" name="json_tutorial-stepset_bikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_json_tutorial-stepset_bikes" title="Open example"> Node.js </label> <div aria-labelledby="tab-json_tutorial-stepset_bikes" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_json_tutorial-stepset_bikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">createClient</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s1">'"Hyperion"'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// "Hyperion" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// [ 'string' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">strLen</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// [10] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">strAppend</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s1">'" (Enduro bikes)"'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// 27 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// ['"Hyperion"" (Enduro bikes)"'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"Deimos"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"crashes"</span><span class="o">:</span> <span class="mi">0</span> <span class="p">},</span> <span class="kc">null</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 }, null ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$[1].crashes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 }, null ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$.[-1]"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 } ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrAppend</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s2">"Norem"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">);</span> <span class="c1">// [ 'Norem' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrInsert</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">,</span> <span class="s2">"Royse"</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">);</span> <span class="c1">// [4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">);</span> <span class="c1">// [ 'Norem', 'Prickett', 'Royse', 'Castilla' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrTrim</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">);</span> <span class="c1">// [ 'Prickett' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res23</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrPop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res23</span><span class="p">);</span> <span class="c1">// [ 'Prickett' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res24</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrPop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res24</span><span class="p">);</span> <span class="c1">// [null] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res25</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"brand"</span><span class="o">:</span> <span class="s2">"Ergonom"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">4972</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res25</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res26</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">objLen</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res26</span><span class="p">);</span> <span class="c1">// [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">objKeys</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27</span><span class="p">);</span> <span class="c1">// [['model', 'brand', 'price']] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">inventoryJSON</span> <span class="o">=</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"inventory"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"mountain_bikes"</span><span class="o">:</span> <span class="p">[{</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:1"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Phoebe"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there\u2019s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"carbon"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">13.1</span> </span></span><span class="line hl"><span class="cl"> <span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line hl"><span class="cl"> <span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:2"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Quaoar"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive."</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">7.9</span> </span></span><span class="line hl"><span class="cl"> <span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"white"</span><span class="p">],</span> </span></span><span class="line hl"><span class="cl"> <span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:3"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Weywot"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get."</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"alloy"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">13.8</span> </span></span><span class="line hl"><span class="cl"> <span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="p">],</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"commuter_bikes"</span><span class="o">:</span> <span class="p">[{</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:4"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Salacia"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, this is a bike which doesn\u2019t break the bank and delivers craved performance. It\u2019s for the rider who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">16.6</span> </span></span><span class="line hl"><span class="cl"> <span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line hl"><span class="cl"> <span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:5"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Mimas"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"alloy"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">11.6</span> </span></span><span class="line hl"><span class="cl"> <span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="p">],</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"><span class="p">};</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res28</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="nx">inventoryJSON</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$.inventory.*"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="cm">/* </span></span></span><span class="line"><span class="cl"><span class="cm">[ </span></span></span><span class="line"><span class="cl"><span class="cm"> [ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:1', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Phoebe', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there’s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 1920, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:2', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Quaoar', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 2072, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:3', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Weywot', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 3264, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm"> ], </span></span></span><span class="line"><span class="cl"><span class="cm"> [ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:4', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Salacia', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano’s, this is a bike which doesn’t break the bank and delivers craved performance. It’s for the rider who wants both efficiency and capability.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 1475, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:5', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Mimas', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 3941, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm"> ] </span></span></span><span class="line"><span class="cl"><span class="cm">] </span></span></span><span class="line"><span class="cl"><span class="cm">*/</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res30</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$.inventory.mountain_bikes[*].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res30</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res31</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s1">'$.inventory["mountain_bikes"][*].model'</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res31</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res32</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[*].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res32</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res33</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res33</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot', 'Salacia', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res34</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[0:2].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res34</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res35</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res35</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="cm">/* </span></span></span><span class="line"><span class="cl"><span class="cm">[ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:2', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Quaoar', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 2072, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: { material: 'aluminium', weight: 7.9 }, </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [ 'black', 'white' ] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm">] </span></span></span><span class="line"><span class="cl"><span class="cm">*/</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1">// names of bikes made from an alloy </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res36</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[?(@.specs.material == 'alloy')].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// ['Weywot', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[?(@.specs.material =~ '(?i)al')].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37</span><span class="p">);</span> <span class="c1">// ['Quaoar', 'Weywot', 'Salacia', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37a</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[0].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37b</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[1].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37c</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[2].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37d</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37d</span><span class="p">);</span> <span class="c1">// ['Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res38</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..price"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res38</span><span class="p">);</span> <span class="c1">// [1920, 2072, 3264, 1475, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res39</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res39</span><span class="p">);</span> <span class="c1">// [1820, 1972, 3164, 1375, 3841] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40</span><span class="p">);</span> <span class="c1">// [1920, 2072, 3264, 1475, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40a</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.*[?(@.price&lt;2000)].price'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mi">1500</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1">// Get all prices from the inventory </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res40b</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$..price'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40b</span><span class="p">);</span> <span class="c1">// [1500, 2072, 3264, 1500, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res41</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrAppend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s2">"pink"</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res41</span><span class="p">);</span> <span class="c1">// [3, 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res42</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[*].colors"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res42</span><span class="p">);</span> <span class="c1">// [['black', 'silver', 'pink'], ['black', 'white'], ['black', 'silver', 'pink']] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_json_tutorial-stepset_bikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_json_tutorial-stepset_bikes" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-json.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_json_tutorial-stepset_bikes" name="json_tutorial-stepset_bikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_json_tutorial-stepset_bikes" title="Open example"> Java </label> <div aria-labelledby="tab-json_tutorial-stepset_bikes" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_json_tutorial-stepset_bikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.json.Path2</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.json.JSONArray</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.json.JSONObject</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">JsonExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">"\"Hyperion\""</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Class</span><span class="o">&lt;?&gt;&gt;</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonType</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [class java.lang.String] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_get' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonStrLen</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [8] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonStrAppend</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">" (Enduro bikes)"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [23] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'str' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">0</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mf">1.5</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="o">-</span><span class="mf">0.75</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'num' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">JSONArray</span><span class="o">()</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"Deimos"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="k">new</span> <span class="n">JSONObject</span><span class="o">().</span><span class="na">put</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="mi">0</span><span class="o">))</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">((</span><span class="n">Object</span><span class="o">)</span> <span class="kc">null</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$[1].crashes"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [0] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonDel</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.[-1]"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="k">new</span> <span class="n">JSONArray</span><span class="o">());</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrAppendWithEscape</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">"Norem"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrInsertWithEscape</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">,</span> <span class="s">"Prickett"</span><span class="o">,</span> <span class="s">"Royce"</span><span class="o">,</span> <span class="s">"Castilla"</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res19</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["Norem","Prickett","Royce","Castilla"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrTrim</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">,</span> <span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res23</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrPop</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res23</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [Prickett] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res24</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrPop</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res24</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [null] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res25</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">JSONObject</span><span class="o">()</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"model"</span><span class="o">,</span> <span class="s">"Deimos"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"brand"</span><span class="o">,</span> <span class="s">"Ergonom"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"price"</span><span class="o">,</span> <span class="mi">4972</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res25</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res26</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonObjLen</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res26</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;&gt;</span> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonObjKeys</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [[price, model, brand]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'obj' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">inventory_json</span> <span class="o">=</span> <span class="s">"{"</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"inventory\": {"</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"mountain_bikes\": ["</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:1\","</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Phoebe\","</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This is a mid-travel trail slayer that is a "</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">"fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for mudguards "</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">"and a rack too. This is the bike for the rider who wants trail manners with "</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">"low fuss ownership.\","</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1920,"</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"carbon\", \"weight\": 13.1},"</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"silver\"]"</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:2\","</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Quaoar\","</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"Redesigned for the 2020 model year, this "</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">"bike impressed our testers and is the best all-around trail bike we've ever "</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">"tested. The Shimano gear system effectively does away with an external cassette, "</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">"so is super low maintenance in terms of wear and tear. All in all it's an "</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">"impressive package for the price, making it very competitive.\","</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 2072,"</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"aluminium\", \"weight\": 7.9},"</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"white\"]"</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:3\","</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Weywot\","</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This bike gives kids aged six years and older "</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">"a durable and uberlight mountain bike for their first experience on tracks and easy "</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">"cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes "</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">"provide ample stopping ability. If you're after a budget option, this is one of the "</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">"best bikes you could get.\","</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3264,"</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"alloy\", \"weight\": 13.8}"</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" ],"</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"commuter_bikes\": ["</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:4\","</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Salacia\","</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This bike is a great option for anyone who just "</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, "</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">"this is a bike which doesn\u2019t break the bank and delivers craved performance. "</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">"It\u2019s for the rider who wants both efficiency and capability.\","</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1475,"</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"aluminium\", \"weight\": 16.6},"</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"silver\"]"</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:5\","</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Mimas\","</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"A real joy to ride, this bike got very high scores "</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">"in last years Bike of the year report. The carefully crafted 50-34 tooth chainset "</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">"and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the "</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">"high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step "</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">"frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb "</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">"throttle. Put it all together and you get a bike that helps redefine what can be "</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">"done for this price.\","</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3941,"</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"alloy\", \"weight\": 11.6}"</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" ]"</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line hl"><span class="cl"> <span class="o">+</span> <span class="s">"}"</span><span class="o">;</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="n">inventory_json</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res28</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [[{"specs":{"material":"carbon","weight":13.1},"price":1920, ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res30</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res30</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res31</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res31</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res32</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res32</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_mtnbikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res33</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..model"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res33</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot","Salacia","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_models' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res34</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[0:2].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res34</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get2mtnbikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res35</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res35</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [{"specs":{"material":"aluminium","weight":7.9},"price":2072,... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter1' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res36</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[?(@.specs.material == 'alloy')].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Weywot","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res37</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res37</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot","Salacia","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter3' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res38</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res38</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter4' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res39</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res39</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res40</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">),</span> <span class="o">-</span><span class="mi">100</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res40</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1820,1972,3164,1375,3841] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res41</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">),</span> <span class="mi">100</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res41</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="o">),</span> <span class="mi">1500</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res42</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res42</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1500,2072,3264,1500,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters1' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res43</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrAppendWithEscape</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"pink\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res43</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [3, 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res44</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[*].colors"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res44</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["black","silver","\"pink\""],["black","white"],["black","silver","\"pink\""]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">close</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_json_tutorial-stepset_bikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_json_tutorial-stepset_bikes" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/JsonExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_json_tutorial-stepset_bikes" name="json_tutorial-stepset_bikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_json_tutorial-stepset_bikes" title="Open example"> Go </label> <div aria-labelledby="tab-json_tutorial-stepset_bikes" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_json_tutorial-stepset_bikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_setget</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Hyperion\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONType</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [[string]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_str</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Hyperion\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONStrLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res4</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 8 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONStrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\" (Enduro bikes)\""</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res5</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 23 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_num</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_arr</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"crashes"</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kc">nil</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$[1].crashes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [0] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONDel</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$.[-1]"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_arr2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{}).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\"Norem\""</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrInsert</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Prickett\""</span><span class="p">,</span> <span class="s">"\"Royce\""</span><span class="p">,</span> <span class="s">"\"Castilla\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Norem", "Prickett", "Royce", "Castilla"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">rangeStop</span> <span class="o">:=</span> <span class="mi">1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrTrimWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONArrTrimArgs</span><span class="p">{</span><span class="nx">Start</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">Stop</span><span class="p">:</span> <span class="o">&amp;</span><span class="nx">rangeStop</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res23</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res23</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res24</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res24</span><span class="p">)</span> <span class="c1">// [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_obj</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res25</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"brand"</span><span class="p">:</span> <span class="s">"Ergonom"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">4972</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res25</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res26</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONObjLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res26</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res27</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONObjKeys</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res27</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [brand model price] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">var</span> <span class="nx">inventory_json</span> <span class="p">=</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"inventory"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"mountain_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This is a mid-travel trail slayer that is a fantastic "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"mudguards and a rack too. This is the bike for the rider who wants "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"carbon"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"Redesigned for the 2020 model year, this bike "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"impressed our testers and is the best all-around trail bike we've "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ever tested. The Shimano gear system effectively does away with an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"external cassette, so is super low maintenance in terms of wear "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"and tear. All in all it's an impressive package for the price, "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"white"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike gives kids aged six years and older "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a durable and uberlight mountain bike for their first experience "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"on tracks and easy cruising through forests and fields. A set of "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ability. If you're after a budget option, this is one of the best "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"commuter_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike is a great option for anyone who just "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"from Shimano\u2019s, this is a bike which doesn\u2019t break the "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bank and delivers craved performance. It\u2019s for the rider "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"A real joy to ride, this bike got very high "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"scores in last years Bike of the year report. The carefully "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"Vittoria Zaffiro tires give balance and grip.It includes "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"conveniently placed thumb throttle. Put it all together and you "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_setbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kd">var</span> <span class="nx">inventory_json</span> <span class="p">=</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"inventory"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"mountain_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line hl"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:1"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Phoebe"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This is a mid-travel trail slayer that is a fantastic "</span> <span class="o">+</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> <span class="o">+</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for "</span> <span class="o">+</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"mudguards and a rack too. This is the bike for the rider who wants "</span> <span class="o">+</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"carbon"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:2"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Quaoar"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"Redesigned for the 2020 model year, this bike "</span> <span class="o">+</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"impressed our testers and is the best all-around trail bike we've "</span> <span class="o">+</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"ever tested. The Shimano gear system effectively does away with an "</span> <span class="o">+</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"external cassette, so is super low maintenance in terms of wear "</span> <span class="o">+</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"and tear. All in all it's an impressive package for the price, "</span> <span class="o">+</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"white"</span><span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:3"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Weywot"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike gives kids aged six years and older "</span> <span class="o">+</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"a durable and uberlight mountain bike for their first experience "</span> <span class="o">+</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"on tracks and easy cruising through forests and fields. A set of "</span> <span class="o">+</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> <span class="o">+</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"ability. If you're after a budget option, this is one of the best "</span> <span class="o">+</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"commuter_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line hl"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:4"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Salacia"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike is a great option for anyone who just "</span> <span class="o">+</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears "</span> <span class="o">+</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"from Shimano\u2019s, this is a bike which doesn\u2019t break the "</span> <span class="o">+</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bank and delivers craved performance. It\u2019s for the rider "</span> <span class="o">+</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:5"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Mimas"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"A real joy to ride, this bike got very high "</span> <span class="o">+</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"scores in last years Bike of the year report. The carefully "</span> <span class="o">+</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> <span class="o">+</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> <span class="o">+</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"Vittoria Zaffiro tires give balance and grip.It includes "</span> <span class="o">+</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> <span class="o">+</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"conveniently placed thumb throttle. Put it all together and you "</span> <span class="o">+</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGetWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONGetArgs</span><span class="p">{</span><span class="nx">Indent</span><span class="p">:</span> <span class="s">" "</span><span class="p">,</span> <span class="nx">Newline</span><span class="p">:</span> <span class="s">"\n"</span><span class="p">,</span> <span class="nx">Space</span><span class="p">:</span> <span class="s">" "</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// { </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "colors": [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "black", </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "silver" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getmtnbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..mountain_bikes[*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getmodels</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..model"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Salacia","Mimas","Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_get2mtnbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..mountain_bikes[0:2].model"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGetWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONGetArgs</span><span class="p">{</span><span class="nx">Indent</span><span class="p">:</span> <span class="s">" "</span><span class="p">,</span> <span class="nx">Newline</span><span class="p">:</span> <span class="s">"\n"</span><span class="p">,</span> <span class="nx">Space</span><span class="p">:</span> <span class="s">" "</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// { </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "colors": [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "black", </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "white" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ], </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "description": "Redesigned for the 2020 model year </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..[?(@.specs.material == 'alloy')].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Mimas","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter3</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Salacia","Mimas","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter4</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatebikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1475,3941,1920,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1375,3841,1820,1972,3164] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1475,3941,1920,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatefilters1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mi">1500</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1500,3941,1500,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatefilters2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"pink\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [3 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..[*].colors"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["black","silver","pink"],["black","silver","pink"],["black","white"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_json_tutorial-stepset_bikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_json_tutorial-stepset_bikes" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/json_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_json_tutorial-stepset_bikes" name="json_tutorial-stepset_bikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_json_tutorial-stepset_bikes" title="Open example"> C# </label> <div aria-labelledby="tab-json_tutorial-stepset_bikes" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_json_tutorial-stepset_bikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.RedisStackCommands</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">Json_tutorial</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\"Hyperion\""</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">JsonType</span><span class="p">[]</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Type</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res3</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; STRING</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_get' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">StrLen</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res4</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 8</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">StrAppend</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">" (Enduro bikes)"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res5</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 23</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'str' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">0</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1.5</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2.5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="p">-</span><span class="m">0.75</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1.75</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'num' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="k">new</span> <span class="kt">object?</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="k">new</span> <span class="p">{</span> <span class="n">crashes</span> <span class="p">=</span> <span class="m">0</span> <span class="p">},</span> <span class="k">null</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$[1].crashes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res13</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [0]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Del</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$.[-1]"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res14</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res15</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="k">new</span> <span class="kt">object</span><span class="p">[]</span> <span class="p">{</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res16</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrAppend</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res17</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res18</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrInsert</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res19</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res20</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem","Prickett","Royce","Castilla"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrTrim</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res21</span><span class="p">));</span> <span class="c1">// 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res22</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span><span class="p">[]</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrPop</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="p">(</span><span class="kt">object</span><span class="p">[])</span><span class="n">res23</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "Prickett"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span><span class="p">[]</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrPop</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="p">(</span><span class="kt">object</span><span class="p">[])</span><span class="n">res24</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; &lt;Empty string&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="p">{</span> <span class="n">model</span> <span class="p">=</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Ergonom"</span><span class="p">,</span> <span class="n">price</span> <span class="p">=</span> <span class="m">4972</span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res25</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ObjLen</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res26</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">IEnumerable</span><span class="p">&lt;</span><span class="n">HashSet</span><span class="p">&lt;</span><span class="kt">string</span><span class="p">&gt;&gt;</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ObjKeys</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res27</span><span class="p">.</span><span class="n">Select</span><span class="p">(</span><span class="n">b</span> <span class="p">=&gt;</span> <span class="s">$"{string.Join("</span><span class="p">,</span> <span class="s">", b.Select(c =&gt; $"</span><span class="p">{</span><span class="n">c</span><span class="p">}</span><span class="s">"))}"</span><span class="p">))</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> <span class="c1">// &gt;&gt;&gt; model, brand, price</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'obj' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">string</span> <span class="n">inventoryJson</span> <span class="p">=</span> <span class="s">@" </span></span></span><span class="line hl"><span class="cl"><span class="s">{ </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""inventory"": { </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""mountain_bikes"": [ </span></span></span><span class="line hl"><span class="cl"><span class="s"> { </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""id"": ""bike:1"", </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""model"": ""Phoebe"", </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""description"": ""This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there\u2019s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership."", </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""price"": 1920, </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""specs"": {""material"": ""carbon"", ""weight"": 13.1}, </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""colors"": [""black"", ""silver""] </span></span></span><span class="line hl"><span class="cl"><span class="s"> }, </span></span></span><span class="line hl"><span class="cl"><span class="s"> { </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""id"": ""bike:2"", </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""model"": ""Quaoar"", </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""description"": ""Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and tear. All in all it's an impressive package for the price, making it very competitive."", </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""price"": 2072, </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""specs"": {""material"": ""aluminium"", ""weight"": 7.9}, </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""colors"": [""black"", ""white""] </span></span></span><span class="line hl"><span class="cl"><span class="s"> }, </span></span></span><span class="line hl"><span class="cl"><span class="s"> { </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""id"": ""bike:3"", </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""model"": ""Weywot"", </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""description"": ""This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get."", </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""price"": 3264, </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""specs"": {""material"": ""alloy"", ""weight"": 13.8} </span></span></span><span class="line hl"><span class="cl"><span class="s"> } </span></span></span><span class="line hl"><span class="cl"><span class="s"> ], </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""commuter_bikes"": [ </span></span></span><span class="line hl"><span class="cl"><span class="s"> { </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""id"": ""bike:4"", </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""model"": ""Salacia"", </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""description"": ""This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, this is a bike which doesn\u2019t break the bank and delivers craved performance. It\u2019s for the rider who wants both efficiency and capability."", </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""price"": 1475, </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""specs"": {""material"": ""aluminium"", ""weight"": 16.6}, </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""colors"": [""black"", ""silver""] </span></span></span><span class="line hl"><span class="cl"><span class="s"> }, </span></span></span><span class="line hl"><span class="cl"><span class="s"> { </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""id"": ""bike:5"", </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""model"": ""Mimas"", </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""description"": ""A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price."", </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""price"": 3941, </span></span></span><span class="line hl"><span class="cl"><span class="s"> ""specs"": {""material"": ""alloy"", ""weight"": 11.6} </span></span></span><span class="line hl"><span class="cl"><span class="s"> } </span></span></span><span class="line hl"><span class="cl"><span class="s"> ] </span></span></span><span class="line hl"><span class="cl"><span class="s"> } </span></span></span><span class="line hl"><span class="cl"><span class="s">}"</span><span class="p">;</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">bool</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">inventoryJson</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res28</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.*"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; {[[{"id":"bike:1","model":"Phoebe", ...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res30</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res32</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res32</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_mtnbikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res33</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res33</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot","Salacia","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_models' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res34</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[0:2].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res34</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get2mtnbikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res35</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res35</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [{"id":"bike:2","model":"Quaoar","description":"Redesigned for the 2020 model year...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter1' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res36</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[?(@.specs.material == 'alloy')].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res36</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Weywot","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res37</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res37</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot","Salacia","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter3' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res38</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res38</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res39</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res39</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res40</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res40</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res41</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res41</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter4' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res42</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..price"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res42</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res43</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="p">-</span><span class="m">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res43</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1820, 1972, 3164, 1375, 3841</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res44</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res44</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1920, 2072, 3264, 1475, 3941</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res45</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">1500</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res45</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res46</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..price"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res46</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [1500,2072,3264,1500,3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters1' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res47</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrAppend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s">"pink"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res47</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 3, 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res48</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[*].colors"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res48</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["black","silver","pink"],["black","white"],["black","silver","pink"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_json_tutorial-stepset_bikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_json_tutorial-stepset_bikes" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/Json_tutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <h3 id="access-examples"> Access examples </h3> <p> The following examples use the <a href="/docs/latest/commands/json.get/"> <code> JSON.GET </code> </a> command to retrieve data from various paths in the JSON document. </p> <p> You can use the wildcard operator <code> * </code> to return a list of all items in the inventory: </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="json_tutorial-stepget_bikes"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_json_tutorial-stepget_bikes" name="json_tutorial-stepget_bikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_json_tutorial-stepget_bikes" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-json_tutorial-stepget_bikes" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_json_tutorial-stepget_bikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">JSON.GET bikes:inventory $.inventory.* </span></span><span class="line hl"><span class="cl">"[[{\"id\":\"bike:1\",\"model\":\"Phoebe\",\"description\":\"This is a mid-travel trail slayer...</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_json_tutorial-stepget_bikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_json_tutorial-stepget_bikes" name="json_tutorial-stepget_bikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_json_tutorial-stepget_bikes" title="Open example"> Python </label> <div aria-labelledby="tab-json_tutorial-stepget_bikes" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_json_tutorial-stepget_bikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for JSON doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/json/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s1">'"Hyperion"'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Hyperion"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['string']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">strlen</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [10]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">strappend</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s1">'" (Enduro bikes)"'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 27</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Hyperion"" (Enduro bikes)"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [2.5]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1.75]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"Deimos"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"crashes"</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span> <span class="kc">None</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['["Deimos", { "crashes": 0 }, null]']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$[1].crashes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['0']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$.[-1]"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Deimos', {'crashes': 0}]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrappend</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s2">"Norem"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Norem']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrinsert</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">,</span> <span class="s2">"Royce"</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [4]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Norem', 'Prickett', 'Royce', 'Castilla']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrtrim</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res21</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res22</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res22</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Prickett']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res23</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrpop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res23</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Prickett"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res24</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrpop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res24</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [None]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res25</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Deimos"</span><span class="p">,</span> <span class="s2">"brand"</span><span class="p">:</span> <span class="s2">"Ergonom"</span><span class="p">,</span> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">4972</span><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res25</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res26</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">objlen</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res26</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [3]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">objkeys</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['model', 'brand', 'price']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">inventory_json</span> <span class="o">=</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"inventory"</span><span class="p">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mountain_bikes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This is a mid-travel trail slayer that is a fantastic "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"gives plenty of gear range to tackle hills and there</span><span class="se">\u2019</span><span class="s2">s room for "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mudguards and a rack too. This is the bike for the rider who wants "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"carbon"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"Redesigned for the 2020 model year, this bike "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"impressed our testers and is the best all-around trail bike we've "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"ever tested. The Shimano gear system effectively does away with an "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"external cassette, so is super low maintenance in terms of wear "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"and tear. All in all it's an impressive package for the price, "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"white"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This bike gives kids aged six years and older "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"a durable and uberlight mountain bike for their first experience "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"on tracks and easy cruising through forests and fields. A set of "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"ability. If you're after a budget option, this is one of the best "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"alloy"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="s2">"commuter_bikes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This bike is a great option for anyone who just "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"wants a bike to get about on With a slick-shifting Claris gears "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"from Shimano</span><span class="se">\u2019</span><span class="s2">s, this is a bike which doesn</span><span class="se">\u2019</span><span class="s2">t break the "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bank and delivers craved performance. It</span><span class="se">\u2019</span><span class="s2">s for the rider "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"A real joy to ride, this bike got very high "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"scores in last years Bike of the year report. The carefully "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"Vittoria Zaffiro tires give balance and grip.It includes "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"conveniently placed thumb throttle. Put it all together and you "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"alloy"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="n">inventory_json</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="c1"># &gt;&gt;&gt; [[{'id': 'bike:1', 'model': 'Phoebe',</span> </span></span><span class="line hl"><span class="cl"><span class="c1"># &gt;&gt;&gt; 'description': 'This is a mid-travel trail slayer...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[*].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s1">'$.inventory["mountain_bikes"][*].model'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..mountain_bikes[*].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot', 'Salacia', 'Mimas']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..mountain_bikes[0:2].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; [{'id': 'bike:2', 'model': 'Quaoar',</span> </span></span><span class="line"><span class="cl"><span class="c1"># 'description': "Redesigned for the 2020 model year...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[?(@.specs.material == 'alloy')].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Weywot', 'Mimas']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Quaoar', 'Weywot', 'Salacia', 'Mimas']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Quaoar', 'Weywot']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1920, 2072, 3264, 1475, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1820, 1972, 3164, 1375, 3841]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1920, 2072, 3264, 1475, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> <span class="mi">1500</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1500, 2072, 3264, 1500, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrappend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s2">"pink"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [3, 3]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[*].colors"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="n">res21</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['black', 'silver', 'pink'], ['black', 'white'], ['black', 'silver', 'pink']]</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_json_tutorial-stepget_bikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_json_tutorial-stepget_bikes" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_json.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_json_tutorial-stepget_bikes" name="json_tutorial-stepget_bikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_json_tutorial-stepget_bikes" title="Open example"> Node.js </label> <div aria-labelledby="tab-json_tutorial-stepget_bikes" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_json_tutorial-stepget_bikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">createClient</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s1">'"Hyperion"'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// "Hyperion" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// [ 'string' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">strLen</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// [10] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">strAppend</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s1">'" (Enduro bikes)"'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// 27 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// ['"Hyperion"" (Enduro bikes)"'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"Deimos"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"crashes"</span><span class="o">:</span> <span class="mi">0</span> <span class="p">},</span> <span class="kc">null</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 }, null ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$[1].crashes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 }, null ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$.[-1]"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 } ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrAppend</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s2">"Norem"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">);</span> <span class="c1">// [ 'Norem' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrInsert</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">,</span> <span class="s2">"Royse"</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">);</span> <span class="c1">// [4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">);</span> <span class="c1">// [ 'Norem', 'Prickett', 'Royse', 'Castilla' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrTrim</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">);</span> <span class="c1">// [ 'Prickett' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res23</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrPop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res23</span><span class="p">);</span> <span class="c1">// [ 'Prickett' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res24</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrPop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res24</span><span class="p">);</span> <span class="c1">// [null] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res25</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"brand"</span><span class="o">:</span> <span class="s2">"Ergonom"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">4972</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res25</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res26</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">objLen</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res26</span><span class="p">);</span> <span class="c1">// [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">objKeys</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27</span><span class="p">);</span> <span class="c1">// [['model', 'brand', 'price']] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">inventoryJSON</span> <span class="o">=</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"inventory"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mountain_bikes"</span><span class="o">:</span> <span class="p">[{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there\u2019s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"carbon"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">13.1</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">7.9</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"white"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"alloy"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">13.8</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="s2">"commuter_bikes"</span><span class="o">:</span> <span class="p">[{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, this is a bike which doesn\u2019t break the bank and delivers craved performance. It\u2019s for the rider who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">16.6</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"alloy"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">11.6</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">};</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="nx">inventoryJSON</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res29</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$.inventory.*"</span> </span></span><span class="line hl"><span class="cl"><span class="p">});</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="cm">/* </span></span></span><span class="line hl"><span class="cl"><span class="cm">[ </span></span></span><span class="line hl"><span class="cl"><span class="cm"> [ </span></span></span><span class="line hl"><span class="cl"><span class="cm"> { </span></span></span><span class="line hl"><span class="cl"><span class="cm"> id: 'bike:1', </span></span></span><span class="line hl"><span class="cl"><span class="cm"> model: 'Phoebe', </span></span></span><span class="line hl"><span class="cl"><span class="cm"> description: 'This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there’s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership.', </span></span></span><span class="line hl"><span class="cl"><span class="cm"> price: 1920, </span></span></span><span class="line hl"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line hl"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line hl"><span class="cl"><span class="cm"> }, </span></span></span><span class="line hl"><span class="cl"><span class="cm"> { </span></span></span><span class="line hl"><span class="cl"><span class="cm"> id: 'bike:2', </span></span></span><span class="line hl"><span class="cl"><span class="cm"> model: 'Quaoar', </span></span></span><span class="line hl"><span class="cl"><span class="cm"> description: "Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive.", </span></span></span><span class="line hl"><span class="cl"><span class="cm"> price: 2072, </span></span></span><span class="line hl"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line hl"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line hl"><span class="cl"><span class="cm"> }, </span></span></span><span class="line hl"><span class="cl"><span class="cm"> { </span></span></span><span class="line hl"><span class="cl"><span class="cm"> id: 'bike:3', </span></span></span><span class="line hl"><span class="cl"><span class="cm"> model: 'Weywot', </span></span></span><span class="line hl"><span class="cl"><span class="cm"> description: "This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get.", </span></span></span><span class="line hl"><span class="cl"><span class="cm"> price: 3264, </span></span></span><span class="line hl"><span class="cl"><span class="cm"> specs: [Object] </span></span></span><span class="line hl"><span class="cl"><span class="cm"> } </span></span></span><span class="line hl"><span class="cl"><span class="cm"> ], </span></span></span><span class="line hl"><span class="cl"><span class="cm"> [ </span></span></span><span class="line hl"><span class="cl"><span class="cm"> { </span></span></span><span class="line hl"><span class="cl"><span class="cm"> id: 'bike:4', </span></span></span><span class="line hl"><span class="cl"><span class="cm"> model: 'Salacia', </span></span></span><span class="line hl"><span class="cl"><span class="cm"> description: 'This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano’s, this is a bike which doesn’t break the bank and delivers craved performance. It’s for the rider who wants both efficiency and capability.', </span></span></span><span class="line hl"><span class="cl"><span class="cm"> price: 1475, </span></span></span><span class="line hl"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line hl"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line hl"><span class="cl"><span class="cm"> }, </span></span></span><span class="line hl"><span class="cl"><span class="cm"> { </span></span></span><span class="line hl"><span class="cl"><span class="cm"> id: 'bike:5', </span></span></span><span class="line hl"><span class="cl"><span class="cm"> model: 'Mimas', </span></span></span><span class="line hl"><span class="cl"><span class="cm"> description: 'A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price.', </span></span></span><span class="line hl"><span class="cl"><span class="cm"> price: 3941, </span></span></span><span class="line hl"><span class="cl"><span class="cm"> specs: [Object] </span></span></span><span class="line hl"><span class="cl"><span class="cm"> } </span></span></span><span class="line hl"><span class="cl"><span class="cm"> ] </span></span></span><span class="line hl"><span class="cl"><span class="cm">] </span></span></span><span class="line hl"><span class="cl"><span class="cm">*/</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res30</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$.inventory.mountain_bikes[*].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res30</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res31</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s1">'$.inventory["mountain_bikes"][*].model'</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res31</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res32</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[*].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res32</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res33</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res33</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot', 'Salacia', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res34</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[0:2].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res34</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res35</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res35</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="cm">/* </span></span></span><span class="line"><span class="cl"><span class="cm">[ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:2', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Quaoar', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 2072, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: { material: 'aluminium', weight: 7.9 }, </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [ 'black', 'white' ] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm">] </span></span></span><span class="line"><span class="cl"><span class="cm">*/</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1">// names of bikes made from an alloy </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res36</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[?(@.specs.material == 'alloy')].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// ['Weywot', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[?(@.specs.material =~ '(?i)al')].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37</span><span class="p">);</span> <span class="c1">// ['Quaoar', 'Weywot', 'Salacia', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37a</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[0].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37b</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[1].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37c</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[2].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37d</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37d</span><span class="p">);</span> <span class="c1">// ['Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res38</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..price"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res38</span><span class="p">);</span> <span class="c1">// [1920, 2072, 3264, 1475, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res39</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res39</span><span class="p">);</span> <span class="c1">// [1820, 1972, 3164, 1375, 3841] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40</span><span class="p">);</span> <span class="c1">// [1920, 2072, 3264, 1475, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40a</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.*[?(@.price&lt;2000)].price'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mi">1500</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1">// Get all prices from the inventory </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res40b</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$..price'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40b</span><span class="p">);</span> <span class="c1">// [1500, 2072, 3264, 1500, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res41</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrAppend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s2">"pink"</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res41</span><span class="p">);</span> <span class="c1">// [3, 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res42</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[*].colors"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res42</span><span class="p">);</span> <span class="c1">// [['black', 'silver', 'pink'], ['black', 'white'], ['black', 'silver', 'pink']] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_json_tutorial-stepget_bikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_json_tutorial-stepget_bikes" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-json.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_json_tutorial-stepget_bikes" name="json_tutorial-stepget_bikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_json_tutorial-stepget_bikes" title="Open example"> Java </label> <div aria-labelledby="tab-json_tutorial-stepget_bikes" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_json_tutorial-stepget_bikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.json.Path2</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.json.JSONArray</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.json.JSONObject</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">JsonExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">"\"Hyperion\""</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Class</span><span class="o">&lt;?&gt;&gt;</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonType</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [class java.lang.String] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_get' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonStrLen</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [8] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonStrAppend</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">" (Enduro bikes)"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [23] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'str' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">0</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mf">1.5</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="o">-</span><span class="mf">0.75</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'num' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">JSONArray</span><span class="o">()</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"Deimos"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="k">new</span> <span class="n">JSONObject</span><span class="o">().</span><span class="na">put</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="mi">0</span><span class="o">))</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">((</span><span class="n">Object</span><span class="o">)</span> <span class="kc">null</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$[1].crashes"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [0] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonDel</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.[-1]"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="k">new</span> <span class="n">JSONArray</span><span class="o">());</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrAppendWithEscape</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">"Norem"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrInsertWithEscape</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">,</span> <span class="s">"Prickett"</span><span class="o">,</span> <span class="s">"Royce"</span><span class="o">,</span> <span class="s">"Castilla"</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res19</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["Norem","Prickett","Royce","Castilla"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrTrim</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">,</span> <span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res23</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrPop</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res23</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [Prickett] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res24</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrPop</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res24</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [null] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res25</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">JSONObject</span><span class="o">()</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"model"</span><span class="o">,</span> <span class="s">"Deimos"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"brand"</span><span class="o">,</span> <span class="s">"Ergonom"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"price"</span><span class="o">,</span> <span class="mi">4972</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res25</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res26</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonObjLen</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res26</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;&gt;</span> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonObjKeys</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [[price, model, brand]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'obj' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">inventory_json</span> <span class="o">=</span> <span class="s">"{"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"inventory\": {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"mountain_bikes\": ["</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:1\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Phoebe\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This is a mid-travel trail slayer that is a "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for mudguards "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and a rack too. This is the bike for the rider who wants trail manners with "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"low fuss ownership.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1920,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"carbon\", \"weight\": 13.1},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"silver\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:2\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Quaoar\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"Redesigned for the 2020 model year, this "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"bike impressed our testers and is the best all-around trail bike we've ever "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"tested. The Shimano gear system effectively does away with an external cassette, "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"so is super low maintenance in terms of wear and tear. All in all it's an "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"impressive package for the price, making it very competitive.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 2072,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"aluminium\", \"weight\": 7.9},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"white\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:3\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Weywot\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This bike gives kids aged six years and older "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"a durable and uberlight mountain bike for their first experience on tracks and easy "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"provide ample stopping ability. If you're after a budget option, this is one of the "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"best bikes you could get.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3264,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"alloy\", \"weight\": 13.8}"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" ],"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"commuter_bikes\": ["</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:4\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Salacia\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This bike is a great option for anyone who just "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"this is a bike which doesn\u2019t break the bank and delivers craved performance. "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"It\u2019s for the rider who wants both efficiency and capability.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1475,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"aluminium\", \"weight\": 16.6},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"silver\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:5\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Mimas\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"A real joy to ride, this bike got very high scores "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"in last years Bike of the year report. The carefully crafted 50-34 tooth chainset "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"throttle. Put it all together and you get a bike that helps redefine what can be "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"done for this price.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3941,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"alloy\", \"weight\": 11.6}"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" ]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"}"</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="n">inventory_json</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res28</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">Object</span> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*"</span><span class="o">));</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [[{"specs":{"material":"carbon","weight":13.1},"price":1920, ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res30</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res30</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res31</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res31</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res32</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res32</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_mtnbikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res33</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..model"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res33</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot","Salacia","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_models' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res34</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[0:2].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res34</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get2mtnbikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res35</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res35</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [{"specs":{"material":"aluminium","weight":7.9},"price":2072,... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter1' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res36</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[?(@.specs.material == 'alloy')].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Weywot","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res37</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res37</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot","Salacia","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter3' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res38</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res38</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter4' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res39</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res39</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res40</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">),</span> <span class="o">-</span><span class="mi">100</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res40</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1820,1972,3164,1375,3841] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res41</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">),</span> <span class="mi">100</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res41</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="o">),</span> <span class="mi">1500</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res42</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res42</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1500,2072,3264,1500,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters1' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res43</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrAppendWithEscape</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"pink\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res43</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [3, 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res44</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[*].colors"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res44</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["black","silver","\"pink\""],["black","white"],["black","silver","\"pink\""]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">close</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_json_tutorial-stepget_bikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_json_tutorial-stepget_bikes" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/JsonExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_json_tutorial-stepget_bikes" name="json_tutorial-stepget_bikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_json_tutorial-stepget_bikes" title="Open example"> Go </label> <div aria-labelledby="tab-json_tutorial-stepget_bikes" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_json_tutorial-stepget_bikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_setget</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Hyperion\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONType</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [[string]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_str</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Hyperion\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONStrLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res4</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 8 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONStrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\" (Enduro bikes)\""</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res5</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 23 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_num</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_arr</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"crashes"</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kc">nil</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$[1].crashes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [0] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONDel</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$.[-1]"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_arr2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{}).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\"Norem\""</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrInsert</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Prickett\""</span><span class="p">,</span> <span class="s">"\"Royce\""</span><span class="p">,</span> <span class="s">"\"Castilla\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Norem", "Prickett", "Royce", "Castilla"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">rangeStop</span> <span class="o">:=</span> <span class="mi">1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrTrimWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONArrTrimArgs</span><span class="p">{</span><span class="nx">Start</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">Stop</span><span class="p">:</span> <span class="o">&amp;</span><span class="nx">rangeStop</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res23</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res23</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res24</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res24</span><span class="p">)</span> <span class="c1">// [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_obj</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res25</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"brand"</span><span class="p">:</span> <span class="s">"Ergonom"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">4972</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res25</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res26</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONObjLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res26</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res27</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONObjKeys</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res27</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [brand model price] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">var</span> <span class="nx">inventory_json</span> <span class="p">=</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"inventory"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"mountain_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This is a mid-travel trail slayer that is a fantastic "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"mudguards and a rack too. This is the bike for the rider who wants "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"carbon"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"Redesigned for the 2020 model year, this bike "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"impressed our testers and is the best all-around trail bike we've "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ever tested. The Shimano gear system effectively does away with an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"external cassette, so is super low maintenance in terms of wear "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"and tear. All in all it's an impressive package for the price, "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"white"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike gives kids aged six years and older "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a durable and uberlight mountain bike for their first experience "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"on tracks and easy cruising through forests and fields. A set of "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ability. If you're after a budget option, this is one of the best "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"commuter_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike is a great option for anyone who just "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"from Shimano\u2019s, this is a bike which doesn\u2019t break the "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bank and delivers craved performance. It\u2019s for the rider "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"A real joy to ride, this bike got very high "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"scores in last years Bike of the year report. The carefully "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"Vittoria Zaffiro tires give balance and grip.It includes "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"conveniently placed thumb throttle. Put it all together and you "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_setbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kd">var</span> <span class="nx">inventory_json</span> <span class="p">=</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"inventory"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"mountain_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This is a mid-travel trail slayer that is a fantastic "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"mudguards and a rack too. This is the bike for the rider who wants "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"carbon"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"Redesigned for the 2020 model year, this bike "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"impressed our testers and is the best all-around trail bike we've "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ever tested. The Shimano gear system effectively does away with an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"external cassette, so is super low maintenance in terms of wear "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"and tear. All in all it's an impressive package for the price, "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"white"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike gives kids aged six years and older "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a durable and uberlight mountain bike for their first experience "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"on tracks and easy cruising through forests and fields. A set of "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ability. If you're after a budget option, this is one of the best "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"commuter_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike is a great option for anyone who just "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"from Shimano\u2019s, this is a bike which doesn\u2019t break the "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bank and delivers craved performance. It\u2019s for the rider "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"A real joy to ride, this bike got very high "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"scores in last years Bike of the year report. The carefully "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"Vittoria Zaffiro tires give balance and grip.It includes "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"conveniently placed thumb throttle. Put it all together and you "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGetWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONGetArgs</span><span class="p">{</span><span class="nx">Indent</span><span class="p">:</span> <span class="s">" "</span><span class="p">,</span> <span class="nx">Newline</span><span class="p">:</span> <span class="s">"\n"</span><span class="p">,</span> <span class="nx">Space</span><span class="p">:</span> <span class="s">" "</span><span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"$.inventory.*"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="c1">// &gt;&gt;&gt; </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="c1">// { </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="c1">// "colors": [ </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="c1">// "black", </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="c1">// "silver" </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="c1">// ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getmtnbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..mountain_bikes[*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getmodels</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..model"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Salacia","Mimas","Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_get2mtnbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..mountain_bikes[0:2].model"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGetWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONGetArgs</span><span class="p">{</span><span class="nx">Indent</span><span class="p">:</span> <span class="s">" "</span><span class="p">,</span> <span class="nx">Newline</span><span class="p">:</span> <span class="s">"\n"</span><span class="p">,</span> <span class="nx">Space</span><span class="p">:</span> <span class="s">" "</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// { </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "colors": [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "black", </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "white" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ], </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "description": "Redesigned for the 2020 model year </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..[?(@.specs.material == 'alloy')].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Mimas","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter3</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Salacia","Mimas","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter4</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatebikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1475,3941,1920,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1375,3841,1820,1972,3164] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1475,3941,1920,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatefilters1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mi">1500</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1500,3941,1500,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatefilters2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"pink\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [3 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..[*].colors"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["black","silver","pink"],["black","silver","pink"],["black","white"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_json_tutorial-stepget_bikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_json_tutorial-stepget_bikes" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/json_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_json_tutorial-stepget_bikes" name="json_tutorial-stepget_bikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_json_tutorial-stepget_bikes" title="Open example"> C# </label> <div aria-labelledby="tab-json_tutorial-stepget_bikes" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_json_tutorial-stepget_bikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.RedisStackCommands</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">Json_tutorial</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\"Hyperion\""</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">JsonType</span><span class="p">[]</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Type</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res3</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; STRING</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_get' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">StrLen</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res4</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 8</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">StrAppend</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">" (Enduro bikes)"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res5</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 23</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'str' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">0</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1.5</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2.5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="p">-</span><span class="m">0.75</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1.75</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'num' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="k">new</span> <span class="kt">object?</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="k">new</span> <span class="p">{</span> <span class="n">crashes</span> <span class="p">=</span> <span class="m">0</span> <span class="p">},</span> <span class="k">null</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$[1].crashes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res13</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [0]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Del</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$.[-1]"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res14</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res15</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="k">new</span> <span class="kt">object</span><span class="p">[]</span> <span class="p">{</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res16</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrAppend</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res17</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res18</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrInsert</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res19</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res20</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem","Prickett","Royce","Castilla"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrTrim</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res21</span><span class="p">));</span> <span class="c1">// 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res22</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span><span class="p">[]</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrPop</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="p">(</span><span class="kt">object</span><span class="p">[])</span><span class="n">res23</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "Prickett"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span><span class="p">[]</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrPop</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="p">(</span><span class="kt">object</span><span class="p">[])</span><span class="n">res24</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; &lt;Empty string&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="p">{</span> <span class="n">model</span> <span class="p">=</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Ergonom"</span><span class="p">,</span> <span class="n">price</span> <span class="p">=</span> <span class="m">4972</span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res25</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ObjLen</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res26</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">IEnumerable</span><span class="p">&lt;</span><span class="n">HashSet</span><span class="p">&lt;</span><span class="kt">string</span><span class="p">&gt;&gt;</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ObjKeys</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res27</span><span class="p">.</span><span class="n">Select</span><span class="p">(</span><span class="n">b</span> <span class="p">=&gt;</span> <span class="s">$"{string.Join("</span><span class="p">,</span> <span class="s">", b.Select(c =&gt; $"</span><span class="p">{</span><span class="n">c</span><span class="p">}</span><span class="s">"))}"</span><span class="p">))</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> <span class="c1">// &gt;&gt;&gt; model, brand, price</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'obj' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">string</span> <span class="n">inventoryJson</span> <span class="p">=</span> <span class="s">@" </span></span></span><span class="line"><span class="cl"><span class="s">{ </span></span></span><span class="line"><span class="cl"><span class="s"> ""inventory"": { </span></span></span><span class="line"><span class="cl"><span class="s"> ""mountain_bikes"": [ </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:1"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Phoebe"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there\u2019s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 1920, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""carbon"", ""weight"": 13.1}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""silver""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:2"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Quaoar"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and tear. All in all it's an impressive package for the price, making it very competitive."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 2072, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""aluminium"", ""weight"": 7.9}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""white""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:3"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Weywot"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 3264, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""alloy"", ""weight"": 13.8} </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s"> ], </span></span></span><span class="line"><span class="cl"><span class="s"> ""commuter_bikes"": [ </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:4"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Salacia"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, this is a bike which doesn\u2019t break the bank and delivers craved performance. It\u2019s for the rider who wants both efficiency and capability."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 1475, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""aluminium"", ""weight"": 16.6}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""silver""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:5"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Mimas"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 3941, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""alloy"", ""weight"": 11.6} </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s"> ] </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s">}"</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">inventoryJson</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res28</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.*"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; {[[{"id":"bike:1","model":"Phoebe", ...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res30</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res32</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res32</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_mtnbikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res33</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res33</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot","Salacia","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_models' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res34</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[0:2].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res34</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get2mtnbikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res35</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res35</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [{"id":"bike:2","model":"Quaoar","description":"Redesigned for the 2020 model year...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter1' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res36</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[?(@.specs.material == 'alloy')].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res36</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Weywot","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res37</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res37</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot","Salacia","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter3' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res38</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res38</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res39</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res39</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res40</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res40</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res41</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res41</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter4' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res42</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..price"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res42</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res43</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="p">-</span><span class="m">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res43</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1820, 1972, 3164, 1375, 3841</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res44</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res44</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1920, 2072, 3264, 1475, 3941</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res45</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">1500</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res45</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res46</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..price"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res46</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [1500,2072,3264,1500,3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters1' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res47</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrAppend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s">"pink"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res47</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 3, 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res48</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[*].colors"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res48</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["black","silver","pink"],["black","white"],["black","silver","pink"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_json_tutorial-stepget_bikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_json_tutorial-stepget_bikes" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/Json_tutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> For some queries, multiple paths can produce the same results. For example, the following paths return the names of all mountain bikes: </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="json_tutorial-stepget_mtnbikes"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_json_tutorial-stepget_mtnbikes" name="json_tutorial-stepget_mtnbikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_json_tutorial-stepget_mtnbikes" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-json_tutorial-stepget_mtnbikes" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_json_tutorial-stepget_mtnbikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; JSON.GET bikes:inventory $.inventory.mountain_bikes[*].model </span></span><span class="line hl"><span class="cl">"[\"Phoebe\",\"Quaoar\",\"Weywot\"]" </span></span><span class="line hl"><span class="cl">&gt; JSON.GET bikes:inventory '$.inventory["mountain_bikes"][*].model' </span></span><span class="line hl"><span class="cl">"[\"Phoebe\",\"Quaoar\",\"Weywot\"]" </span></span><span class="line hl"><span class="cl">&gt; JSON.GET bikes:inventory '$..mountain_bikes[*].model' </span></span><span class="line hl"><span class="cl">"[\"Phoebe\",\"Quaoar\",\"Weywot\"]"</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_json_tutorial-stepget_mtnbikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_json_tutorial-stepget_mtnbikes" name="json_tutorial-stepget_mtnbikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_json_tutorial-stepget_mtnbikes" title="Open example"> Python </label> <div aria-labelledby="tab-json_tutorial-stepget_mtnbikes" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_json_tutorial-stepget_mtnbikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for JSON doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/json/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s1">'"Hyperion"'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Hyperion"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['string']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">strlen</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [10]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">strappend</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s1">'" (Enduro bikes)"'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 27</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Hyperion"" (Enduro bikes)"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [2.5]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1.75]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"Deimos"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"crashes"</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span> <span class="kc">None</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['["Deimos", { "crashes": 0 }, null]']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$[1].crashes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['0']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$.[-1]"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Deimos', {'crashes': 0}]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrappend</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s2">"Norem"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Norem']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrinsert</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">,</span> <span class="s2">"Royce"</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [4]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Norem', 'Prickett', 'Royce', 'Castilla']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrtrim</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res21</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res22</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res22</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Prickett']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res23</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrpop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res23</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Prickett"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res24</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrpop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res24</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [None]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res25</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Deimos"</span><span class="p">,</span> <span class="s2">"brand"</span><span class="p">:</span> <span class="s2">"Ergonom"</span><span class="p">,</span> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">4972</span><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res25</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res26</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">objlen</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res26</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [3]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">objkeys</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['model', 'brand', 'price']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">inventory_json</span> <span class="o">=</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"inventory"</span><span class="p">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mountain_bikes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This is a mid-travel trail slayer that is a fantastic "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"gives plenty of gear range to tackle hills and there</span><span class="se">\u2019</span><span class="s2">s room for "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mudguards and a rack too. This is the bike for the rider who wants "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"carbon"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"Redesigned for the 2020 model year, this bike "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"impressed our testers and is the best all-around trail bike we've "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"ever tested. The Shimano gear system effectively does away with an "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"external cassette, so is super low maintenance in terms of wear "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"and tear. All in all it's an impressive package for the price, "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"white"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This bike gives kids aged six years and older "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"a durable and uberlight mountain bike for their first experience "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"on tracks and easy cruising through forests and fields. A set of "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"ability. If you're after a budget option, this is one of the best "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"alloy"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="s2">"commuter_bikes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This bike is a great option for anyone who just "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"wants a bike to get about on With a slick-shifting Claris gears "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"from Shimano</span><span class="se">\u2019</span><span class="s2">s, this is a bike which doesn</span><span class="se">\u2019</span><span class="s2">t break the "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bank and delivers craved performance. It</span><span class="se">\u2019</span><span class="s2">s for the rider "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"A real joy to ride, this bike got very high "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"scores in last years Bike of the year report. The carefully "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"Vittoria Zaffiro tires give balance and grip.It includes "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"conveniently placed thumb throttle. Put it all together and you "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"alloy"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="n">inventory_json</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; [[{'id': 'bike:1', 'model': 'Phoebe',</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 'description': 'This is a mid-travel trail slayer...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[*].model"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s1">'$.inventory["mountain_bikes"][*].model'</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..mountain_bikes[*].model"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot', 'Salacia', 'Mimas']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..mountain_bikes[0:2].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; [{'id': 'bike:2', 'model': 'Quaoar',</span> </span></span><span class="line"><span class="cl"><span class="c1"># 'description': "Redesigned for the 2020 model year...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[?(@.specs.material == 'alloy')].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Weywot', 'Mimas']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Quaoar', 'Weywot', 'Salacia', 'Mimas']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Quaoar', 'Weywot']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1920, 2072, 3264, 1475, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1820, 1972, 3164, 1375, 3841]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1920, 2072, 3264, 1475, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> <span class="mi">1500</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1500, 2072, 3264, 1500, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrappend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s2">"pink"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [3, 3]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[*].colors"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="n">res21</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['black', 'silver', 'pink'], ['black', 'white'], ['black', 'silver', 'pink']]</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_json_tutorial-stepget_mtnbikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_json_tutorial-stepget_mtnbikes" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_json.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_json_tutorial-stepget_mtnbikes" name="json_tutorial-stepget_mtnbikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_json_tutorial-stepget_mtnbikes" title="Open example"> Node.js </label> <div aria-labelledby="tab-json_tutorial-stepget_mtnbikes" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_json_tutorial-stepget_mtnbikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">createClient</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s1">'"Hyperion"'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// "Hyperion" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// [ 'string' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">strLen</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// [10] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">strAppend</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s1">'" (Enduro bikes)"'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// 27 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// ['"Hyperion"" (Enduro bikes)"'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"Deimos"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"crashes"</span><span class="o">:</span> <span class="mi">0</span> <span class="p">},</span> <span class="kc">null</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 }, null ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$[1].crashes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 }, null ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$.[-1]"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 } ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrAppend</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s2">"Norem"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">);</span> <span class="c1">// [ 'Norem' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrInsert</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">,</span> <span class="s2">"Royse"</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">);</span> <span class="c1">// [4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">);</span> <span class="c1">// [ 'Norem', 'Prickett', 'Royse', 'Castilla' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrTrim</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">);</span> <span class="c1">// [ 'Prickett' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res23</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrPop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res23</span><span class="p">);</span> <span class="c1">// [ 'Prickett' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res24</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrPop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res24</span><span class="p">);</span> <span class="c1">// [null] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res25</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"brand"</span><span class="o">:</span> <span class="s2">"Ergonom"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">4972</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res25</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res26</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">objLen</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res26</span><span class="p">);</span> <span class="c1">// [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">objKeys</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27</span><span class="p">);</span> <span class="c1">// [['model', 'brand', 'price']] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">inventoryJSON</span> <span class="o">=</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"inventory"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mountain_bikes"</span><span class="o">:</span> <span class="p">[{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there\u2019s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"carbon"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">13.1</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">7.9</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"white"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"alloy"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">13.8</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="s2">"commuter_bikes"</span><span class="o">:</span> <span class="p">[{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, this is a bike which doesn\u2019t break the bank and delivers craved performance. It\u2019s for the rider who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">16.6</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"alloy"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">11.6</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">};</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="nx">inventoryJSON</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$.inventory.*"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="cm">/* </span></span></span><span class="line"><span class="cl"><span class="cm">[ </span></span></span><span class="line"><span class="cl"><span class="cm"> [ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:1', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Phoebe', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there’s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 1920, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:2', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Quaoar', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 2072, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:3', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Weywot', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 3264, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm"> ], </span></span></span><span class="line"><span class="cl"><span class="cm"> [ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:4', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Salacia', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano’s, this is a bike which doesn’t break the bank and delivers craved performance. It’s for the rider who wants both efficiency and capability.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 1475, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:5', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Mimas', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 3941, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm"> ] </span></span></span><span class="line"><span class="cl"><span class="cm">] </span></span></span><span class="line"><span class="cl"><span class="cm">*/</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res30</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$.inventory.mountain_bikes[*].model"</span> </span></span><span class="line hl"><span class="cl"><span class="p">});</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res30</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res31</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s1">'$.inventory["mountain_bikes"][*].model'</span> </span></span><span class="line hl"><span class="cl"><span class="p">});</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res31</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res32</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[*].model"</span> </span></span><span class="line hl"><span class="cl"><span class="p">});</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res32</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res33</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res33</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot', 'Salacia', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res34</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[0:2].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res34</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res35</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res35</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="cm">/* </span></span></span><span class="line"><span class="cl"><span class="cm">[ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:2', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Quaoar', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 2072, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: { material: 'aluminium', weight: 7.9 }, </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [ 'black', 'white' ] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm">] </span></span></span><span class="line"><span class="cl"><span class="cm">*/</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1">// names of bikes made from an alloy </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res36</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[?(@.specs.material == 'alloy')].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// ['Weywot', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[?(@.specs.material =~ '(?i)al')].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37</span><span class="p">);</span> <span class="c1">// ['Quaoar', 'Weywot', 'Salacia', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37a</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[0].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37b</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[1].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37c</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[2].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37d</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37d</span><span class="p">);</span> <span class="c1">// ['Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res38</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..price"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res38</span><span class="p">);</span> <span class="c1">// [1920, 2072, 3264, 1475, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res39</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res39</span><span class="p">);</span> <span class="c1">// [1820, 1972, 3164, 1375, 3841] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40</span><span class="p">);</span> <span class="c1">// [1920, 2072, 3264, 1475, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40a</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.*[?(@.price&lt;2000)].price'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mi">1500</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1">// Get all prices from the inventory </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res40b</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$..price'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40b</span><span class="p">);</span> <span class="c1">// [1500, 2072, 3264, 1500, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res41</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrAppend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s2">"pink"</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res41</span><span class="p">);</span> <span class="c1">// [3, 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res42</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[*].colors"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res42</span><span class="p">);</span> <span class="c1">// [['black', 'silver', 'pink'], ['black', 'white'], ['black', 'silver', 'pink']] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_json_tutorial-stepget_mtnbikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_json_tutorial-stepget_mtnbikes" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-json.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_json_tutorial-stepget_mtnbikes" name="json_tutorial-stepget_mtnbikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_json_tutorial-stepget_mtnbikes" title="Open example"> Java </label> <div aria-labelledby="tab-json_tutorial-stepget_mtnbikes" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_json_tutorial-stepget_mtnbikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.json.Path2</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.json.JSONArray</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.json.JSONObject</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">JsonExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">"\"Hyperion\""</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Class</span><span class="o">&lt;?&gt;&gt;</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonType</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [class java.lang.String] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_get' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonStrLen</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [8] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonStrAppend</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">" (Enduro bikes)"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [23] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'str' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">0</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mf">1.5</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="o">-</span><span class="mf">0.75</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'num' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">JSONArray</span><span class="o">()</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"Deimos"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="k">new</span> <span class="n">JSONObject</span><span class="o">().</span><span class="na">put</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="mi">0</span><span class="o">))</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">((</span><span class="n">Object</span><span class="o">)</span> <span class="kc">null</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$[1].crashes"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [0] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonDel</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.[-1]"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="k">new</span> <span class="n">JSONArray</span><span class="o">());</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrAppendWithEscape</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">"Norem"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrInsertWithEscape</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">,</span> <span class="s">"Prickett"</span><span class="o">,</span> <span class="s">"Royce"</span><span class="o">,</span> <span class="s">"Castilla"</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res19</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["Norem","Prickett","Royce","Castilla"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrTrim</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">,</span> <span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res23</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrPop</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res23</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [Prickett] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res24</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrPop</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res24</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [null] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res25</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">JSONObject</span><span class="o">()</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"model"</span><span class="o">,</span> <span class="s">"Deimos"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"brand"</span><span class="o">,</span> <span class="s">"Ergonom"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"price"</span><span class="o">,</span> <span class="mi">4972</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res25</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res26</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonObjLen</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res26</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;&gt;</span> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonObjKeys</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [[price, model, brand]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'obj' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">inventory_json</span> <span class="o">=</span> <span class="s">"{"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"inventory\": {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"mountain_bikes\": ["</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:1\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Phoebe\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This is a mid-travel trail slayer that is a "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for mudguards "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and a rack too. This is the bike for the rider who wants trail manners with "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"low fuss ownership.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1920,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"carbon\", \"weight\": 13.1},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"silver\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:2\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Quaoar\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"Redesigned for the 2020 model year, this "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"bike impressed our testers and is the best all-around trail bike we've ever "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"tested. The Shimano gear system effectively does away with an external cassette, "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"so is super low maintenance in terms of wear and tear. All in all it's an "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"impressive package for the price, making it very competitive.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 2072,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"aluminium\", \"weight\": 7.9},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"white\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:3\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Weywot\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This bike gives kids aged six years and older "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"a durable and uberlight mountain bike for their first experience on tracks and easy "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"provide ample stopping ability. If you're after a budget option, this is one of the "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"best bikes you could get.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3264,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"alloy\", \"weight\": 13.8}"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" ],"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"commuter_bikes\": ["</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:4\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Salacia\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This bike is a great option for anyone who just "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"this is a bike which doesn\u2019t break the bank and delivers craved performance. "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"It\u2019s for the rider who wants both efficiency and capability.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1475,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"aluminium\", \"weight\": 16.6},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"silver\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:5\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Mimas\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"A real joy to ride, this bike got very high scores "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"in last years Bike of the year report. The carefully crafted 50-34 tooth chainset "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"throttle. Put it all together and you get a bike that helps redefine what can be "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"done for this price.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3941,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"alloy\", \"weight\": 11.6}"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" ]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"}"</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="n">inventory_json</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res28</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [[{"specs":{"material":"carbon","weight":13.1},"price":1920, ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">Object</span> <span class="n">res30</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="o">)</span> </span></span><span class="line hl"><span class="cl"> <span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res30</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">Object</span> <span class="n">res31</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="o">)</span> </span></span><span class="line hl"><span class="cl"> <span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res31</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">Object</span> <span class="n">res32</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[*].model"</span><span class="o">)</span> </span></span><span class="line hl"><span class="cl"> <span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res32</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_mtnbikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res33</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..model"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res33</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot","Salacia","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_models' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res34</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[0:2].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res34</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get2mtnbikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res35</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res35</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [{"specs":{"material":"aluminium","weight":7.9},"price":2072,... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter1' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res36</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[?(@.specs.material == 'alloy')].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Weywot","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res37</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res37</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot","Salacia","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter3' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res38</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res38</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter4' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res39</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res39</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res40</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">),</span> <span class="o">-</span><span class="mi">100</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res40</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1820,1972,3164,1375,3841] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res41</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">),</span> <span class="mi">100</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res41</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="o">),</span> <span class="mi">1500</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res42</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res42</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1500,2072,3264,1500,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters1' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res43</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrAppendWithEscape</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"pink\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res43</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [3, 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res44</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[*].colors"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res44</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["black","silver","\"pink\""],["black","white"],["black","silver","\"pink\""]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">close</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_json_tutorial-stepget_mtnbikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_json_tutorial-stepget_mtnbikes" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/JsonExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_json_tutorial-stepget_mtnbikes" name="json_tutorial-stepget_mtnbikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_json_tutorial-stepget_mtnbikes" title="Open example"> Go </label> <div aria-labelledby="tab-json_tutorial-stepget_mtnbikes" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_json_tutorial-stepget_mtnbikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_setget</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Hyperion\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONType</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [[string]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_str</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Hyperion\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONStrLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res4</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 8 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONStrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\" (Enduro bikes)\""</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res5</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 23 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_num</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_arr</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"crashes"</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kc">nil</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$[1].crashes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [0] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONDel</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$.[-1]"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_arr2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{}).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\"Norem\""</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrInsert</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Prickett\""</span><span class="p">,</span> <span class="s">"\"Royce\""</span><span class="p">,</span> <span class="s">"\"Castilla\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Norem", "Prickett", "Royce", "Castilla"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">rangeStop</span> <span class="o">:=</span> <span class="mi">1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrTrimWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONArrTrimArgs</span><span class="p">{</span><span class="nx">Start</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">Stop</span><span class="p">:</span> <span class="o">&amp;</span><span class="nx">rangeStop</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res23</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res23</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res24</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res24</span><span class="p">)</span> <span class="c1">// [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_obj</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res25</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"brand"</span><span class="p">:</span> <span class="s">"Ergonom"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">4972</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res25</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res26</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONObjLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res26</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res27</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONObjKeys</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res27</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [brand model price] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">var</span> <span class="nx">inventory_json</span> <span class="p">=</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"inventory"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"mountain_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This is a mid-travel trail slayer that is a fantastic "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"mudguards and a rack too. This is the bike for the rider who wants "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"carbon"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"Redesigned for the 2020 model year, this bike "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"impressed our testers and is the best all-around trail bike we've "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ever tested. The Shimano gear system effectively does away with an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"external cassette, so is super low maintenance in terms of wear "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"and tear. All in all it's an impressive package for the price, "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"white"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike gives kids aged six years and older "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a durable and uberlight mountain bike for their first experience "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"on tracks and easy cruising through forests and fields. A set of "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ability. If you're after a budget option, this is one of the best "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"commuter_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike is a great option for anyone who just "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"from Shimano\u2019s, this is a bike which doesn\u2019t break the "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bank and delivers craved performance. It\u2019s for the rider "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"A real joy to ride, this bike got very high "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"scores in last years Bike of the year report. The carefully "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"Vittoria Zaffiro tires give balance and grip.It includes "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"conveniently placed thumb throttle. Put it all together and you "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_setbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kd">var</span> <span class="nx">inventory_json</span> <span class="p">=</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"inventory"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"mountain_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This is a mid-travel trail slayer that is a fantastic "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"mudguards and a rack too. This is the bike for the rider who wants "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"carbon"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"Redesigned for the 2020 model year, this bike "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"impressed our testers and is the best all-around trail bike we've "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ever tested. The Shimano gear system effectively does away with an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"external cassette, so is super low maintenance in terms of wear "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"and tear. All in all it's an impressive package for the price, "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"white"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike gives kids aged six years and older "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a durable and uberlight mountain bike for their first experience "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"on tracks and easy cruising through forests and fields. A set of "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ability. If you're after a budget option, this is one of the best "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"commuter_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike is a great option for anyone who just "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"from Shimano\u2019s, this is a bike which doesn\u2019t break the "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bank and delivers craved performance. It\u2019s for the rider "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"A real joy to ride, this bike got very high "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"scores in last years Bike of the year report. The carefully "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"Vittoria Zaffiro tires give balance and grip.It includes "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"conveniently placed thumb throttle. Put it all together and you "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGetWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONGetArgs</span><span class="p">{</span><span class="nx">Indent</span><span class="p">:</span> <span class="s">" "</span><span class="p">,</span> <span class="nx">Newline</span><span class="p">:</span> <span class="s">"\n"</span><span class="p">,</span> <span class="nx">Space</span><span class="p">:</span> <span class="s">" "</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// { </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "colors": [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "black", </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "silver" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getmtnbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..mountain_bikes[*].model"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getmodels</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..model"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Salacia","Mimas","Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_get2mtnbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..mountain_bikes[0:2].model"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGetWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONGetArgs</span><span class="p">{</span><span class="nx">Indent</span><span class="p">:</span> <span class="s">" "</span><span class="p">,</span> <span class="nx">Newline</span><span class="p">:</span> <span class="s">"\n"</span><span class="p">,</span> <span class="nx">Space</span><span class="p">:</span> <span class="s">" "</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// { </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "colors": [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "black", </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "white" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ], </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "description": "Redesigned for the 2020 model year </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..[?(@.specs.material == 'alloy')].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Mimas","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter3</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Salacia","Mimas","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter4</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatebikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1475,3941,1920,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1375,3841,1820,1972,3164] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1475,3941,1920,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatefilters1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mi">1500</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1500,3941,1500,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatefilters2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"pink\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [3 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..[*].colors"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["black","silver","pink"],["black","silver","pink"],["black","white"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_json_tutorial-stepget_mtnbikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_json_tutorial-stepget_mtnbikes" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/json_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_json_tutorial-stepget_mtnbikes" name="json_tutorial-stepget_mtnbikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_json_tutorial-stepget_mtnbikes" title="Open example"> C# </label> <div aria-labelledby="tab-json_tutorial-stepget_mtnbikes" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_json_tutorial-stepget_mtnbikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.RedisStackCommands</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">Json_tutorial</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\"Hyperion\""</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">JsonType</span><span class="p">[]</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Type</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res3</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; STRING</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_get' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">StrLen</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res4</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 8</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">StrAppend</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">" (Enduro bikes)"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res5</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 23</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'str' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">0</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1.5</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2.5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="p">-</span><span class="m">0.75</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1.75</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'num' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="k">new</span> <span class="kt">object?</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="k">new</span> <span class="p">{</span> <span class="n">crashes</span> <span class="p">=</span> <span class="m">0</span> <span class="p">},</span> <span class="k">null</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$[1].crashes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res13</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [0]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Del</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$.[-1]"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res14</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res15</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="k">new</span> <span class="kt">object</span><span class="p">[]</span> <span class="p">{</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res16</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrAppend</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res17</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res18</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrInsert</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res19</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res20</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem","Prickett","Royce","Castilla"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrTrim</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res21</span><span class="p">));</span> <span class="c1">// 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res22</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span><span class="p">[]</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrPop</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="p">(</span><span class="kt">object</span><span class="p">[])</span><span class="n">res23</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "Prickett"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span><span class="p">[]</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrPop</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="p">(</span><span class="kt">object</span><span class="p">[])</span><span class="n">res24</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; &lt;Empty string&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="p">{</span> <span class="n">model</span> <span class="p">=</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Ergonom"</span><span class="p">,</span> <span class="n">price</span> <span class="p">=</span> <span class="m">4972</span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res25</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ObjLen</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res26</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">IEnumerable</span><span class="p">&lt;</span><span class="n">HashSet</span><span class="p">&lt;</span><span class="kt">string</span><span class="p">&gt;&gt;</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ObjKeys</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res27</span><span class="p">.</span><span class="n">Select</span><span class="p">(</span><span class="n">b</span> <span class="p">=&gt;</span> <span class="s">$"{string.Join("</span><span class="p">,</span> <span class="s">", b.Select(c =&gt; $"</span><span class="p">{</span><span class="n">c</span><span class="p">}</span><span class="s">"))}"</span><span class="p">))</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> <span class="c1">// &gt;&gt;&gt; model, brand, price</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'obj' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">string</span> <span class="n">inventoryJson</span> <span class="p">=</span> <span class="s">@" </span></span></span><span class="line"><span class="cl"><span class="s">{ </span></span></span><span class="line"><span class="cl"><span class="s"> ""inventory"": { </span></span></span><span class="line"><span class="cl"><span class="s"> ""mountain_bikes"": [ </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:1"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Phoebe"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there\u2019s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 1920, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""carbon"", ""weight"": 13.1}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""silver""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:2"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Quaoar"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and tear. All in all it's an impressive package for the price, making it very competitive."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 2072, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""aluminium"", ""weight"": 7.9}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""white""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:3"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Weywot"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 3264, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""alloy"", ""weight"": 13.8} </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s"> ], </span></span></span><span class="line"><span class="cl"><span class="s"> ""commuter_bikes"": [ </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:4"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Salacia"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, this is a bike which doesn\u2019t break the bank and delivers craved performance. It\u2019s for the rider who wants both efficiency and capability."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 1475, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""aluminium"", ""weight"": 16.6}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""silver""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:5"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Mimas"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 3941, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""alloy"", ""weight"": 11.6} </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s"> ] </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s">}"</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">inventoryJson</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res28</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.*"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; {[[{"id":"bike:1","model":"Phoebe", ...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res30</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res32</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[*].model"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res32</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_mtnbikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res33</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res33</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot","Salacia","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_models' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res34</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[0:2].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res34</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get2mtnbikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res35</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res35</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [{"id":"bike:2","model":"Quaoar","description":"Redesigned for the 2020 model year...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter1' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res36</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[?(@.specs.material == 'alloy')].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res36</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Weywot","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res37</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res37</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot","Salacia","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter3' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res38</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res38</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res39</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res39</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res40</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res40</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res41</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res41</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter4' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res42</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..price"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res42</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res43</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="p">-</span><span class="m">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res43</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1820, 1972, 3164, 1375, 3841</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res44</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res44</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1920, 2072, 3264, 1475, 3941</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res45</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">1500</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res45</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res46</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..price"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res46</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [1500,2072,3264,1500,3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters1' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res47</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrAppend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s">"pink"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res47</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 3, 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res48</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[*].colors"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res48</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["black","silver","pink"],["black","white"],["black","silver","pink"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_json_tutorial-stepget_mtnbikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_json_tutorial-stepget_mtnbikes" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/Json_tutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> The recursive descent operator <code> .. </code> can retrieve a field from multiple sections of a JSON document. The following example returns the names of all inventory items: </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="json_tutorial-stepget_models"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_json_tutorial-stepget_models" name="json_tutorial-stepget_models" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_json_tutorial-stepget_models" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-json_tutorial-stepget_models" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_json_tutorial-stepget_models" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; JSON.GET bikes:inventory $..model </span></span><span class="line hl"><span class="cl">"[\"Phoebe\",\"Quaoar\",\"Weywot\",\"Salacia\",\"Mimas\"]"</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_json_tutorial-stepget_models')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_json_tutorial-stepget_models" name="json_tutorial-stepget_models" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_json_tutorial-stepget_models" title="Open example"> Python </label> <div aria-labelledby="tab-json_tutorial-stepget_models" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_json_tutorial-stepget_models" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for JSON doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/json/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s1">'"Hyperion"'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Hyperion"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['string']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">strlen</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [10]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">strappend</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s1">'" (Enduro bikes)"'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 27</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Hyperion"" (Enduro bikes)"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [2.5]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1.75]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"Deimos"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"crashes"</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span> <span class="kc">None</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['["Deimos", { "crashes": 0 }, null]']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$[1].crashes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['0']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$.[-1]"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Deimos', {'crashes': 0}]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrappend</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s2">"Norem"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Norem']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrinsert</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">,</span> <span class="s2">"Royce"</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [4]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Norem', 'Prickett', 'Royce', 'Castilla']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrtrim</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res21</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res22</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res22</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Prickett']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res23</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrpop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res23</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Prickett"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res24</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrpop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res24</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [None]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res25</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Deimos"</span><span class="p">,</span> <span class="s2">"brand"</span><span class="p">:</span> <span class="s2">"Ergonom"</span><span class="p">,</span> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">4972</span><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res25</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res26</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">objlen</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res26</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [3]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">objkeys</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['model', 'brand', 'price']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">inventory_json</span> <span class="o">=</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"inventory"</span><span class="p">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mountain_bikes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This is a mid-travel trail slayer that is a fantastic "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"gives plenty of gear range to tackle hills and there</span><span class="se">\u2019</span><span class="s2">s room for "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mudguards and a rack too. This is the bike for the rider who wants "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"carbon"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"Redesigned for the 2020 model year, this bike "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"impressed our testers and is the best all-around trail bike we've "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"ever tested. The Shimano gear system effectively does away with an "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"external cassette, so is super low maintenance in terms of wear "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"and tear. All in all it's an impressive package for the price, "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"white"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This bike gives kids aged six years and older "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"a durable and uberlight mountain bike for their first experience "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"on tracks and easy cruising through forests and fields. A set of "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"ability. If you're after a budget option, this is one of the best "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"alloy"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="s2">"commuter_bikes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This bike is a great option for anyone who just "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"wants a bike to get about on With a slick-shifting Claris gears "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"from Shimano</span><span class="se">\u2019</span><span class="s2">s, this is a bike which doesn</span><span class="se">\u2019</span><span class="s2">t break the "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bank and delivers craved performance. It</span><span class="se">\u2019</span><span class="s2">s for the rider "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"A real joy to ride, this bike got very high "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"scores in last years Bike of the year report. The carefully "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"Vittoria Zaffiro tires give balance and grip.It includes "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"conveniently placed thumb throttle. Put it all together and you "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"alloy"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="n">inventory_json</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; [[{'id': 'bike:1', 'model': 'Phoebe',</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 'description': 'This is a mid-travel trail slayer...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[*].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s1">'$.inventory["mountain_bikes"][*].model'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..mountain_bikes[*].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..model"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot', 'Salacia', 'Mimas']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..mountain_bikes[0:2].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; [{'id': 'bike:2', 'model': 'Quaoar',</span> </span></span><span class="line"><span class="cl"><span class="c1"># 'description': "Redesigned for the 2020 model year...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[?(@.specs.material == 'alloy')].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Weywot', 'Mimas']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Quaoar', 'Weywot', 'Salacia', 'Mimas']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Quaoar', 'Weywot']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1920, 2072, 3264, 1475, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1820, 1972, 3164, 1375, 3841]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1920, 2072, 3264, 1475, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> <span class="mi">1500</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1500, 2072, 3264, 1500, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrappend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s2">"pink"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [3, 3]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[*].colors"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="n">res21</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['black', 'silver', 'pink'], ['black', 'white'], ['black', 'silver', 'pink']]</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_json_tutorial-stepget_models')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_json_tutorial-stepget_models" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_json.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_json_tutorial-stepget_models" name="json_tutorial-stepget_models" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_json_tutorial-stepget_models" title="Open example"> Node.js </label> <div aria-labelledby="tab-json_tutorial-stepget_models" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_json_tutorial-stepget_models" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">createClient</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s1">'"Hyperion"'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// "Hyperion" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// [ 'string' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">strLen</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// [10] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">strAppend</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s1">'" (Enduro bikes)"'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// 27 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// ['"Hyperion"" (Enduro bikes)"'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"Deimos"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"crashes"</span><span class="o">:</span> <span class="mi">0</span> <span class="p">},</span> <span class="kc">null</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 }, null ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$[1].crashes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 }, null ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$.[-1]"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 } ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrAppend</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s2">"Norem"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">);</span> <span class="c1">// [ 'Norem' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrInsert</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">,</span> <span class="s2">"Royse"</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">);</span> <span class="c1">// [4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">);</span> <span class="c1">// [ 'Norem', 'Prickett', 'Royse', 'Castilla' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrTrim</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">);</span> <span class="c1">// [ 'Prickett' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res23</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrPop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res23</span><span class="p">);</span> <span class="c1">// [ 'Prickett' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res24</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrPop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res24</span><span class="p">);</span> <span class="c1">// [null] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res25</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"brand"</span><span class="o">:</span> <span class="s2">"Ergonom"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">4972</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res25</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res26</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">objLen</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res26</span><span class="p">);</span> <span class="c1">// [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">objKeys</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27</span><span class="p">);</span> <span class="c1">// [['model', 'brand', 'price']] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">inventoryJSON</span> <span class="o">=</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"inventory"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mountain_bikes"</span><span class="o">:</span> <span class="p">[{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there\u2019s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"carbon"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">13.1</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">7.9</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"white"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"alloy"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">13.8</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="s2">"commuter_bikes"</span><span class="o">:</span> <span class="p">[{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, this is a bike which doesn\u2019t break the bank and delivers craved performance. It\u2019s for the rider who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">16.6</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"alloy"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">11.6</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">};</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="nx">inventoryJSON</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$.inventory.*"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="cm">/* </span></span></span><span class="line"><span class="cl"><span class="cm">[ </span></span></span><span class="line"><span class="cl"><span class="cm"> [ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:1', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Phoebe', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there’s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 1920, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:2', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Quaoar', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 2072, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:3', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Weywot', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 3264, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm"> ], </span></span></span><span class="line"><span class="cl"><span class="cm"> [ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:4', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Salacia', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano’s, this is a bike which doesn’t break the bank and delivers craved performance. It’s for the rider who wants both efficiency and capability.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 1475, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:5', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Mimas', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 3941, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm"> ] </span></span></span><span class="line"><span class="cl"><span class="cm">] </span></span></span><span class="line"><span class="cl"><span class="cm">*/</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res30</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$.inventory.mountain_bikes[*].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res30</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res31</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s1">'$.inventory["mountain_bikes"][*].model'</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res31</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res32</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[*].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res32</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res33</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..model"</span> </span></span><span class="line hl"><span class="cl"><span class="p">});</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res33</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot', 'Salacia', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res34</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[0:2].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res34</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res35</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res35</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="cm">/* </span></span></span><span class="line"><span class="cl"><span class="cm">[ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:2', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Quaoar', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 2072, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: { material: 'aluminium', weight: 7.9 }, </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [ 'black', 'white' ] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm">] </span></span></span><span class="line"><span class="cl"><span class="cm">*/</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1">// names of bikes made from an alloy </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res36</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[?(@.specs.material == 'alloy')].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// ['Weywot', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[?(@.specs.material =~ '(?i)al')].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37</span><span class="p">);</span> <span class="c1">// ['Quaoar', 'Weywot', 'Salacia', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37a</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[0].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37b</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[1].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37c</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[2].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37d</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37d</span><span class="p">);</span> <span class="c1">// ['Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res38</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..price"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res38</span><span class="p">);</span> <span class="c1">// [1920, 2072, 3264, 1475, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res39</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res39</span><span class="p">);</span> <span class="c1">// [1820, 1972, 3164, 1375, 3841] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40</span><span class="p">);</span> <span class="c1">// [1920, 2072, 3264, 1475, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40a</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.*[?(@.price&lt;2000)].price'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mi">1500</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1">// Get all prices from the inventory </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res40b</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$..price'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40b</span><span class="p">);</span> <span class="c1">// [1500, 2072, 3264, 1500, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res41</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrAppend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s2">"pink"</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res41</span><span class="p">);</span> <span class="c1">// [3, 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res42</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[*].colors"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res42</span><span class="p">);</span> <span class="c1">// [['black', 'silver', 'pink'], ['black', 'white'], ['black', 'silver', 'pink']] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_json_tutorial-stepget_models')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_json_tutorial-stepget_models" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-json.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_json_tutorial-stepget_models" name="json_tutorial-stepget_models" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_json_tutorial-stepget_models" title="Open example"> Java </label> <div aria-labelledby="tab-json_tutorial-stepget_models" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_json_tutorial-stepget_models" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.json.Path2</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.json.JSONArray</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.json.JSONObject</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">JsonExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">"\"Hyperion\""</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Class</span><span class="o">&lt;?&gt;&gt;</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonType</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [class java.lang.String] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_get' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonStrLen</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [8] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonStrAppend</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">" (Enduro bikes)"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [23] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'str' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">0</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mf">1.5</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="o">-</span><span class="mf">0.75</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'num' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">JSONArray</span><span class="o">()</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"Deimos"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="k">new</span> <span class="n">JSONObject</span><span class="o">().</span><span class="na">put</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="mi">0</span><span class="o">))</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">((</span><span class="n">Object</span><span class="o">)</span> <span class="kc">null</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$[1].crashes"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [0] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonDel</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.[-1]"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="k">new</span> <span class="n">JSONArray</span><span class="o">());</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrAppendWithEscape</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">"Norem"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrInsertWithEscape</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">,</span> <span class="s">"Prickett"</span><span class="o">,</span> <span class="s">"Royce"</span><span class="o">,</span> <span class="s">"Castilla"</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res19</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["Norem","Prickett","Royce","Castilla"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrTrim</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">,</span> <span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res23</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrPop</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res23</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [Prickett] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res24</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrPop</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res24</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [null] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res25</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">JSONObject</span><span class="o">()</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"model"</span><span class="o">,</span> <span class="s">"Deimos"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"brand"</span><span class="o">,</span> <span class="s">"Ergonom"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"price"</span><span class="o">,</span> <span class="mi">4972</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res25</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res26</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonObjLen</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res26</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;&gt;</span> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonObjKeys</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [[price, model, brand]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'obj' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">inventory_json</span> <span class="o">=</span> <span class="s">"{"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"inventory\": {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"mountain_bikes\": ["</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:1\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Phoebe\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This is a mid-travel trail slayer that is a "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for mudguards "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and a rack too. This is the bike for the rider who wants trail manners with "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"low fuss ownership.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1920,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"carbon\", \"weight\": 13.1},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"silver\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:2\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Quaoar\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"Redesigned for the 2020 model year, this "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"bike impressed our testers and is the best all-around trail bike we've ever "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"tested. The Shimano gear system effectively does away with an external cassette, "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"so is super low maintenance in terms of wear and tear. All in all it's an "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"impressive package for the price, making it very competitive.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 2072,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"aluminium\", \"weight\": 7.9},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"white\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:3\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Weywot\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This bike gives kids aged six years and older "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"a durable and uberlight mountain bike for their first experience on tracks and easy "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"provide ample stopping ability. If you're after a budget option, this is one of the "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"best bikes you could get.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3264,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"alloy\", \"weight\": 13.8}"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" ],"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"commuter_bikes\": ["</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:4\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Salacia\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This bike is a great option for anyone who just "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"this is a bike which doesn\u2019t break the bank and delivers craved performance. "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"It\u2019s for the rider who wants both efficiency and capability.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1475,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"aluminium\", \"weight\": 16.6},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"silver\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:5\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Mimas\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"A real joy to ride, this bike got very high scores "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"in last years Bike of the year report. The carefully crafted 50-34 tooth chainset "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"throttle. Put it all together and you get a bike that helps redefine what can be "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"done for this price.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3941,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"alloy\", \"weight\": 11.6}"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" ]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"}"</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="n">inventory_json</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res28</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [[{"specs":{"material":"carbon","weight":13.1},"price":1920, ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res30</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res30</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res31</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res31</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res32</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res32</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_mtnbikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">Object</span> <span class="n">res33</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..model"</span><span class="o">));</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res33</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot","Salacia","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_models' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res34</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[0:2].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res34</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get2mtnbikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res35</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res35</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [{"specs":{"material":"aluminium","weight":7.9},"price":2072,... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter1' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res36</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[?(@.specs.material == 'alloy')].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Weywot","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res37</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res37</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot","Salacia","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter3' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res38</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res38</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter4' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res39</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res39</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res40</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">),</span> <span class="o">-</span><span class="mi">100</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res40</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1820,1972,3164,1375,3841] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res41</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">),</span> <span class="mi">100</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res41</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="o">),</span> <span class="mi">1500</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res42</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res42</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1500,2072,3264,1500,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters1' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res43</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrAppendWithEscape</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"pink\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res43</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [3, 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res44</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[*].colors"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res44</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["black","silver","\"pink\""],["black","white"],["black","silver","\"pink\""]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">close</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_json_tutorial-stepget_models')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_json_tutorial-stepget_models" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/JsonExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_json_tutorial-stepget_models" name="json_tutorial-stepget_models" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_json_tutorial-stepget_models" title="Open example"> Go </label> <div aria-labelledby="tab-json_tutorial-stepget_models" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_json_tutorial-stepget_models" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_setget</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Hyperion\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONType</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [[string]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_str</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Hyperion\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONStrLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res4</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 8 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONStrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\" (Enduro bikes)\""</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res5</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 23 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_num</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_arr</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"crashes"</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kc">nil</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$[1].crashes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [0] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONDel</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$.[-1]"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_arr2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{}).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\"Norem\""</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrInsert</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Prickett\""</span><span class="p">,</span> <span class="s">"\"Royce\""</span><span class="p">,</span> <span class="s">"\"Castilla\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Norem", "Prickett", "Royce", "Castilla"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">rangeStop</span> <span class="o">:=</span> <span class="mi">1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrTrimWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONArrTrimArgs</span><span class="p">{</span><span class="nx">Start</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">Stop</span><span class="p">:</span> <span class="o">&amp;</span><span class="nx">rangeStop</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res23</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res23</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res24</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res24</span><span class="p">)</span> <span class="c1">// [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_obj</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res25</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"brand"</span><span class="p">:</span> <span class="s">"Ergonom"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">4972</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res25</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res26</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONObjLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res26</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res27</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONObjKeys</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res27</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [brand model price] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">var</span> <span class="nx">inventory_json</span> <span class="p">=</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"inventory"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"mountain_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This is a mid-travel trail slayer that is a fantastic "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"mudguards and a rack too. This is the bike for the rider who wants "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"carbon"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"Redesigned for the 2020 model year, this bike "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"impressed our testers and is the best all-around trail bike we've "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ever tested. The Shimano gear system effectively does away with an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"external cassette, so is super low maintenance in terms of wear "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"and tear. All in all it's an impressive package for the price, "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"white"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike gives kids aged six years and older "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a durable and uberlight mountain bike for their first experience "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"on tracks and easy cruising through forests and fields. A set of "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ability. If you're after a budget option, this is one of the best "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"commuter_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike is a great option for anyone who just "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"from Shimano\u2019s, this is a bike which doesn\u2019t break the "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bank and delivers craved performance. It\u2019s for the rider "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"A real joy to ride, this bike got very high "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"scores in last years Bike of the year report. The carefully "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"Vittoria Zaffiro tires give balance and grip.It includes "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"conveniently placed thumb throttle. Put it all together and you "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_setbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kd">var</span> <span class="nx">inventory_json</span> <span class="p">=</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"inventory"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"mountain_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This is a mid-travel trail slayer that is a fantastic "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"mudguards and a rack too. This is the bike for the rider who wants "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"carbon"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"Redesigned for the 2020 model year, this bike "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"impressed our testers and is the best all-around trail bike we've "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ever tested. The Shimano gear system effectively does away with an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"external cassette, so is super low maintenance in terms of wear "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"and tear. All in all it's an impressive package for the price, "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"white"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike gives kids aged six years and older "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a durable and uberlight mountain bike for their first experience "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"on tracks and easy cruising through forests and fields. A set of "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ability. If you're after a budget option, this is one of the best "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"commuter_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike is a great option for anyone who just "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"from Shimano\u2019s, this is a bike which doesn\u2019t break the "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bank and delivers craved performance. It\u2019s for the rider "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"A real joy to ride, this bike got very high "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"scores in last years Bike of the year report. The carefully "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"Vittoria Zaffiro tires give balance and grip.It includes "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"conveniently placed thumb throttle. Put it all together and you "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGetWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONGetArgs</span><span class="p">{</span><span class="nx">Indent</span><span class="p">:</span> <span class="s">" "</span><span class="p">,</span> <span class="nx">Newline</span><span class="p">:</span> <span class="s">"\n"</span><span class="p">,</span> <span class="nx">Space</span><span class="p">:</span> <span class="s">" "</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// { </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "colors": [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "black", </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "silver" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getmtnbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..mountain_bikes[*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getmodels</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..model"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Salacia","Mimas","Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_get2mtnbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..mountain_bikes[0:2].model"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGetWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONGetArgs</span><span class="p">{</span><span class="nx">Indent</span><span class="p">:</span> <span class="s">" "</span><span class="p">,</span> <span class="nx">Newline</span><span class="p">:</span> <span class="s">"\n"</span><span class="p">,</span> <span class="nx">Space</span><span class="p">:</span> <span class="s">" "</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// { </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "colors": [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "black", </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "white" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ], </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "description": "Redesigned for the 2020 model year </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..[?(@.specs.material == 'alloy')].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Mimas","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter3</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Salacia","Mimas","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter4</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatebikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1475,3941,1920,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1375,3841,1820,1972,3164] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1475,3941,1920,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatefilters1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mi">1500</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1500,3941,1500,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatefilters2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"pink\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [3 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..[*].colors"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["black","silver","pink"],["black","silver","pink"],["black","white"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_json_tutorial-stepget_models')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_json_tutorial-stepget_models" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/json_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_json_tutorial-stepget_models" name="json_tutorial-stepget_models" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_json_tutorial-stepget_models" title="Open example"> C# </label> <div aria-labelledby="tab-json_tutorial-stepget_models" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_json_tutorial-stepget_models" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.RedisStackCommands</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">Json_tutorial</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\"Hyperion\""</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">JsonType</span><span class="p">[]</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Type</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res3</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; STRING</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_get' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">StrLen</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res4</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 8</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">StrAppend</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">" (Enduro bikes)"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res5</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 23</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'str' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">0</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1.5</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2.5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="p">-</span><span class="m">0.75</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1.75</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'num' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="k">new</span> <span class="kt">object?</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="k">new</span> <span class="p">{</span> <span class="n">crashes</span> <span class="p">=</span> <span class="m">0</span> <span class="p">},</span> <span class="k">null</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$[1].crashes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res13</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [0]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Del</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$.[-1]"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res14</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res15</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="k">new</span> <span class="kt">object</span><span class="p">[]</span> <span class="p">{</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res16</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrAppend</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res17</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res18</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrInsert</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res19</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res20</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem","Prickett","Royce","Castilla"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrTrim</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res21</span><span class="p">));</span> <span class="c1">// 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res22</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span><span class="p">[]</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrPop</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="p">(</span><span class="kt">object</span><span class="p">[])</span><span class="n">res23</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "Prickett"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span><span class="p">[]</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrPop</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="p">(</span><span class="kt">object</span><span class="p">[])</span><span class="n">res24</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; &lt;Empty string&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="p">{</span> <span class="n">model</span> <span class="p">=</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Ergonom"</span><span class="p">,</span> <span class="n">price</span> <span class="p">=</span> <span class="m">4972</span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res25</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ObjLen</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res26</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">IEnumerable</span><span class="p">&lt;</span><span class="n">HashSet</span><span class="p">&lt;</span><span class="kt">string</span><span class="p">&gt;&gt;</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ObjKeys</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res27</span><span class="p">.</span><span class="n">Select</span><span class="p">(</span><span class="n">b</span> <span class="p">=&gt;</span> <span class="s">$"{string.Join("</span><span class="p">,</span> <span class="s">", b.Select(c =&gt; $"</span><span class="p">{</span><span class="n">c</span><span class="p">}</span><span class="s">"))}"</span><span class="p">))</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> <span class="c1">// &gt;&gt;&gt; model, brand, price</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'obj' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">string</span> <span class="n">inventoryJson</span> <span class="p">=</span> <span class="s">@" </span></span></span><span class="line"><span class="cl"><span class="s">{ </span></span></span><span class="line"><span class="cl"><span class="s"> ""inventory"": { </span></span></span><span class="line"><span class="cl"><span class="s"> ""mountain_bikes"": [ </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:1"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Phoebe"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there\u2019s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 1920, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""carbon"", ""weight"": 13.1}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""silver""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:2"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Quaoar"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and tear. All in all it's an impressive package for the price, making it very competitive."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 2072, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""aluminium"", ""weight"": 7.9}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""white""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:3"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Weywot"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 3264, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""alloy"", ""weight"": 13.8} </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s"> ], </span></span></span><span class="line"><span class="cl"><span class="s"> ""commuter_bikes"": [ </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:4"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Salacia"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, this is a bike which doesn\u2019t break the bank and delivers craved performance. It\u2019s for the rider who wants both efficiency and capability."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 1475, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""aluminium"", ""weight"": 16.6}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""silver""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:5"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Mimas"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 3941, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""alloy"", ""weight"": 11.6} </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s"> ] </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s">}"</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">inventoryJson</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res28</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.*"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; {[[{"id":"bike:1","model":"Phoebe", ...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res30</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res32</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res32</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_mtnbikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res33</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..model"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res33</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot","Salacia","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_models' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res34</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[0:2].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res34</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get2mtnbikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res35</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res35</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [{"id":"bike:2","model":"Quaoar","description":"Redesigned for the 2020 model year...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter1' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res36</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[?(@.specs.material == 'alloy')].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res36</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Weywot","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res37</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res37</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot","Salacia","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter3' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res38</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res38</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res39</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res39</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res40</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res40</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res41</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res41</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter4' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res42</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..price"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res42</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res43</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="p">-</span><span class="m">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res43</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1820, 1972, 3164, 1375, 3841</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res44</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res44</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1920, 2072, 3264, 1475, 3941</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res45</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">1500</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res45</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res46</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..price"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res46</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [1500,2072,3264,1500,3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters1' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res47</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrAppend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s">"pink"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res47</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 3, 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res48</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[*].colors"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res48</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["black","silver","pink"],["black","white"],["black","silver","pink"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_json_tutorial-stepget_models')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_json_tutorial-stepget_models" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/Json_tutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> You can use an array slice to select a range of elements from an array. This example returns the names of the first 2 mountain bikes: </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="json_tutorial-stepget2mtnbikes"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_json_tutorial-stepget2mtnbikes" name="json_tutorial-stepget2mtnbikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_json_tutorial-stepget2mtnbikes" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-json_tutorial-stepget2mtnbikes" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_json_tutorial-stepget2mtnbikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; JSON.GET bikes:inventory $..mountain_bikes[0:2].model </span></span><span class="line hl"><span class="cl">"[\"Phoebe\",\"Quaoar\"]"</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_json_tutorial-stepget2mtnbikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_json_tutorial-stepget2mtnbikes" name="json_tutorial-stepget2mtnbikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_json_tutorial-stepget2mtnbikes" title="Open example"> Python </label> <div aria-labelledby="tab-json_tutorial-stepget2mtnbikes" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_json_tutorial-stepget2mtnbikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for JSON doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/json/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s1">'"Hyperion"'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Hyperion"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['string']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">strlen</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [10]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">strappend</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s1">'" (Enduro bikes)"'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 27</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Hyperion"" (Enduro bikes)"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [2.5]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1.75]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"Deimos"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"crashes"</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span> <span class="kc">None</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['["Deimos", { "crashes": 0 }, null]']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$[1].crashes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['0']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$.[-1]"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Deimos', {'crashes': 0}]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrappend</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s2">"Norem"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Norem']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrinsert</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">,</span> <span class="s2">"Royce"</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [4]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Norem', 'Prickett', 'Royce', 'Castilla']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrtrim</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res21</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res22</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res22</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Prickett']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res23</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrpop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res23</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Prickett"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res24</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrpop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res24</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [None]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res25</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Deimos"</span><span class="p">,</span> <span class="s2">"brand"</span><span class="p">:</span> <span class="s2">"Ergonom"</span><span class="p">,</span> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">4972</span><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res25</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res26</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">objlen</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res26</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [3]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">objkeys</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['model', 'brand', 'price']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">inventory_json</span> <span class="o">=</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"inventory"</span><span class="p">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mountain_bikes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This is a mid-travel trail slayer that is a fantastic "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"gives plenty of gear range to tackle hills and there</span><span class="se">\u2019</span><span class="s2">s room for "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mudguards and a rack too. This is the bike for the rider who wants "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"carbon"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"Redesigned for the 2020 model year, this bike "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"impressed our testers and is the best all-around trail bike we've "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"ever tested. The Shimano gear system effectively does away with an "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"external cassette, so is super low maintenance in terms of wear "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"and tear. All in all it's an impressive package for the price, "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"white"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This bike gives kids aged six years and older "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"a durable and uberlight mountain bike for their first experience "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"on tracks and easy cruising through forests and fields. A set of "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"ability. If you're after a budget option, this is one of the best "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"alloy"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="s2">"commuter_bikes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This bike is a great option for anyone who just "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"wants a bike to get about on With a slick-shifting Claris gears "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"from Shimano</span><span class="se">\u2019</span><span class="s2">s, this is a bike which doesn</span><span class="se">\u2019</span><span class="s2">t break the "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bank and delivers craved performance. It</span><span class="se">\u2019</span><span class="s2">s for the rider "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"A real joy to ride, this bike got very high "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"scores in last years Bike of the year report. The carefully "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"Vittoria Zaffiro tires give balance and grip.It includes "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"conveniently placed thumb throttle. Put it all together and you "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"alloy"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="n">inventory_json</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; [[{'id': 'bike:1', 'model': 'Phoebe',</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 'description': 'This is a mid-travel trail slayer...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[*].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s1">'$.inventory["mountain_bikes"][*].model'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..mountain_bikes[*].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot', 'Salacia', 'Mimas']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..mountain_bikes[0:2].model"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; [{'id': 'bike:2', 'model': 'Quaoar',</span> </span></span><span class="line"><span class="cl"><span class="c1"># 'description': "Redesigned for the 2020 model year...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[?(@.specs.material == 'alloy')].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Weywot', 'Mimas']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Quaoar', 'Weywot', 'Salacia', 'Mimas']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Quaoar', 'Weywot']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1920, 2072, 3264, 1475, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1820, 1972, 3164, 1375, 3841]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1920, 2072, 3264, 1475, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> <span class="mi">1500</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1500, 2072, 3264, 1500, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrappend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s2">"pink"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [3, 3]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[*].colors"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="n">res21</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['black', 'silver', 'pink'], ['black', 'white'], ['black', 'silver', 'pink']]</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_json_tutorial-stepget2mtnbikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_json_tutorial-stepget2mtnbikes" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_json.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_json_tutorial-stepget2mtnbikes" name="json_tutorial-stepget2mtnbikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_json_tutorial-stepget2mtnbikes" title="Open example"> Node.js </label> <div aria-labelledby="tab-json_tutorial-stepget2mtnbikes" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_json_tutorial-stepget2mtnbikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">createClient</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s1">'"Hyperion"'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// "Hyperion" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// [ 'string' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">strLen</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// [10] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">strAppend</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s1">'" (Enduro bikes)"'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// 27 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// ['"Hyperion"" (Enduro bikes)"'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"Deimos"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"crashes"</span><span class="o">:</span> <span class="mi">0</span> <span class="p">},</span> <span class="kc">null</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 }, null ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$[1].crashes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 }, null ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$.[-1]"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 } ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrAppend</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s2">"Norem"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">);</span> <span class="c1">// [ 'Norem' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrInsert</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">,</span> <span class="s2">"Royse"</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">);</span> <span class="c1">// [4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">);</span> <span class="c1">// [ 'Norem', 'Prickett', 'Royse', 'Castilla' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrTrim</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">);</span> <span class="c1">// [ 'Prickett' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res23</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrPop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res23</span><span class="p">);</span> <span class="c1">// [ 'Prickett' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res24</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrPop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res24</span><span class="p">);</span> <span class="c1">// [null] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res25</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"brand"</span><span class="o">:</span> <span class="s2">"Ergonom"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">4972</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res25</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res26</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">objLen</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res26</span><span class="p">);</span> <span class="c1">// [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">objKeys</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27</span><span class="p">);</span> <span class="c1">// [['model', 'brand', 'price']] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">inventoryJSON</span> <span class="o">=</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"inventory"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mountain_bikes"</span><span class="o">:</span> <span class="p">[{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there\u2019s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"carbon"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">13.1</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">7.9</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"white"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"alloy"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">13.8</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="s2">"commuter_bikes"</span><span class="o">:</span> <span class="p">[{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, this is a bike which doesn\u2019t break the bank and delivers craved performance. It\u2019s for the rider who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">16.6</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"alloy"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">11.6</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">};</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="nx">inventoryJSON</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$.inventory.*"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="cm">/* </span></span></span><span class="line"><span class="cl"><span class="cm">[ </span></span></span><span class="line"><span class="cl"><span class="cm"> [ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:1', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Phoebe', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there’s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 1920, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:2', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Quaoar', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 2072, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:3', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Weywot', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 3264, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm"> ], </span></span></span><span class="line"><span class="cl"><span class="cm"> [ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:4', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Salacia', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano’s, this is a bike which doesn’t break the bank and delivers craved performance. It’s for the rider who wants both efficiency and capability.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 1475, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:5', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Mimas', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 3941, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm"> ] </span></span></span><span class="line"><span class="cl"><span class="cm">] </span></span></span><span class="line"><span class="cl"><span class="cm">*/</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res30</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$.inventory.mountain_bikes[*].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res30</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res31</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s1">'$.inventory["mountain_bikes"][*].model'</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res31</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res32</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[*].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res32</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res33</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res33</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot', 'Salacia', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res34</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[0:2].model"</span> </span></span><span class="line hl"><span class="cl"><span class="p">});</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res34</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res35</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res35</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="cm">/* </span></span></span><span class="line"><span class="cl"><span class="cm">[ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:2', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Quaoar', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 2072, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: { material: 'aluminium', weight: 7.9 }, </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [ 'black', 'white' ] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm">] </span></span></span><span class="line"><span class="cl"><span class="cm">*/</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1">// names of bikes made from an alloy </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res36</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[?(@.specs.material == 'alloy')].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// ['Weywot', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[?(@.specs.material =~ '(?i)al')].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37</span><span class="p">);</span> <span class="c1">// ['Quaoar', 'Weywot', 'Salacia', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37a</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[0].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37b</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[1].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37c</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[2].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37d</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37d</span><span class="p">);</span> <span class="c1">// ['Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res38</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..price"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res38</span><span class="p">);</span> <span class="c1">// [1920, 2072, 3264, 1475, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res39</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res39</span><span class="p">);</span> <span class="c1">// [1820, 1972, 3164, 1375, 3841] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40</span><span class="p">);</span> <span class="c1">// [1920, 2072, 3264, 1475, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40a</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.*[?(@.price&lt;2000)].price'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mi">1500</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1">// Get all prices from the inventory </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res40b</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$..price'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40b</span><span class="p">);</span> <span class="c1">// [1500, 2072, 3264, 1500, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res41</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrAppend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s2">"pink"</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res41</span><span class="p">);</span> <span class="c1">// [3, 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res42</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[*].colors"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res42</span><span class="p">);</span> <span class="c1">// [['black', 'silver', 'pink'], ['black', 'white'], ['black', 'silver', 'pink']] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_json_tutorial-stepget2mtnbikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_json_tutorial-stepget2mtnbikes" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-json.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_json_tutorial-stepget2mtnbikes" name="json_tutorial-stepget2mtnbikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_json_tutorial-stepget2mtnbikes" title="Open example"> Java </label> <div aria-labelledby="tab-json_tutorial-stepget2mtnbikes" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_json_tutorial-stepget2mtnbikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.json.Path2</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.json.JSONArray</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.json.JSONObject</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">JsonExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">"\"Hyperion\""</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Class</span><span class="o">&lt;?&gt;&gt;</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonType</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [class java.lang.String] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_get' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonStrLen</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [8] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonStrAppend</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">" (Enduro bikes)"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [23] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'str' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">0</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mf">1.5</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="o">-</span><span class="mf">0.75</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'num' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">JSONArray</span><span class="o">()</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"Deimos"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="k">new</span> <span class="n">JSONObject</span><span class="o">().</span><span class="na">put</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="mi">0</span><span class="o">))</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">((</span><span class="n">Object</span><span class="o">)</span> <span class="kc">null</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$[1].crashes"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [0] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonDel</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.[-1]"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="k">new</span> <span class="n">JSONArray</span><span class="o">());</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrAppendWithEscape</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">"Norem"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrInsertWithEscape</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">,</span> <span class="s">"Prickett"</span><span class="o">,</span> <span class="s">"Royce"</span><span class="o">,</span> <span class="s">"Castilla"</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res19</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["Norem","Prickett","Royce","Castilla"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrTrim</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">,</span> <span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res23</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrPop</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res23</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [Prickett] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res24</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrPop</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res24</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [null] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res25</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">JSONObject</span><span class="o">()</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"model"</span><span class="o">,</span> <span class="s">"Deimos"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"brand"</span><span class="o">,</span> <span class="s">"Ergonom"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"price"</span><span class="o">,</span> <span class="mi">4972</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res25</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res26</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonObjLen</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res26</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;&gt;</span> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonObjKeys</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [[price, model, brand]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'obj' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">inventory_json</span> <span class="o">=</span> <span class="s">"{"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"inventory\": {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"mountain_bikes\": ["</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:1\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Phoebe\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This is a mid-travel trail slayer that is a "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for mudguards "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and a rack too. This is the bike for the rider who wants trail manners with "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"low fuss ownership.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1920,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"carbon\", \"weight\": 13.1},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"silver\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:2\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Quaoar\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"Redesigned for the 2020 model year, this "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"bike impressed our testers and is the best all-around trail bike we've ever "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"tested. The Shimano gear system effectively does away with an external cassette, "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"so is super low maintenance in terms of wear and tear. All in all it's an "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"impressive package for the price, making it very competitive.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 2072,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"aluminium\", \"weight\": 7.9},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"white\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:3\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Weywot\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This bike gives kids aged six years and older "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"a durable and uberlight mountain bike for their first experience on tracks and easy "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"provide ample stopping ability. If you're after a budget option, this is one of the "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"best bikes you could get.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3264,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"alloy\", \"weight\": 13.8}"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" ],"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"commuter_bikes\": ["</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:4\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Salacia\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This bike is a great option for anyone who just "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"this is a bike which doesn\u2019t break the bank and delivers craved performance. "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"It\u2019s for the rider who wants both efficiency and capability.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1475,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"aluminium\", \"weight\": 16.6},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"silver\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:5\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Mimas\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"A real joy to ride, this bike got very high scores "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"in last years Bike of the year report. The carefully crafted 50-34 tooth chainset "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"throttle. Put it all together and you get a bike that helps redefine what can be "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"done for this price.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3941,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"alloy\", \"weight\": 11.6}"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" ]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"}"</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="n">inventory_json</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res28</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [[{"specs":{"material":"carbon","weight":13.1},"price":1920, ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res30</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res30</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res31</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res31</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res32</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res32</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_mtnbikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res33</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..model"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res33</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot","Salacia","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_models' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">Object</span> <span class="n">res34</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[0:2].model"</span><span class="o">)</span> </span></span><span class="line hl"><span class="cl"> <span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res34</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get2mtnbikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res35</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res35</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [{"specs":{"material":"aluminium","weight":7.9},"price":2072,... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter1' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res36</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[?(@.specs.material == 'alloy')].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Weywot","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res37</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res37</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot","Salacia","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter3' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res38</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res38</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter4' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res39</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res39</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res40</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">),</span> <span class="o">-</span><span class="mi">100</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res40</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1820,1972,3164,1375,3841] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res41</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">),</span> <span class="mi">100</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res41</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="o">),</span> <span class="mi">1500</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res42</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res42</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1500,2072,3264,1500,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters1' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res43</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrAppendWithEscape</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"pink\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res43</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [3, 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res44</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[*].colors"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res44</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["black","silver","\"pink\""],["black","white"],["black","silver","\"pink\""]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">close</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_json_tutorial-stepget2mtnbikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_json_tutorial-stepget2mtnbikes" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/JsonExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_json_tutorial-stepget2mtnbikes" name="json_tutorial-stepget2mtnbikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_json_tutorial-stepget2mtnbikes" title="Open example"> Go </label> <div aria-labelledby="tab-json_tutorial-stepget2mtnbikes" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_json_tutorial-stepget2mtnbikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_setget</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Hyperion\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONType</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [[string]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_str</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Hyperion\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONStrLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res4</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 8 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONStrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\" (Enduro bikes)\""</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res5</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 23 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_num</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_arr</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"crashes"</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kc">nil</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$[1].crashes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [0] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONDel</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$.[-1]"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_arr2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{}).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\"Norem\""</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrInsert</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Prickett\""</span><span class="p">,</span> <span class="s">"\"Royce\""</span><span class="p">,</span> <span class="s">"\"Castilla\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Norem", "Prickett", "Royce", "Castilla"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">rangeStop</span> <span class="o">:=</span> <span class="mi">1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrTrimWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONArrTrimArgs</span><span class="p">{</span><span class="nx">Start</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">Stop</span><span class="p">:</span> <span class="o">&amp;</span><span class="nx">rangeStop</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res23</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res23</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res24</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res24</span><span class="p">)</span> <span class="c1">// [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_obj</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res25</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"brand"</span><span class="p">:</span> <span class="s">"Ergonom"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">4972</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res25</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res26</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONObjLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res26</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res27</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONObjKeys</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res27</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [brand model price] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">var</span> <span class="nx">inventory_json</span> <span class="p">=</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"inventory"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"mountain_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This is a mid-travel trail slayer that is a fantastic "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"mudguards and a rack too. This is the bike for the rider who wants "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"carbon"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"Redesigned for the 2020 model year, this bike "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"impressed our testers and is the best all-around trail bike we've "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ever tested. The Shimano gear system effectively does away with an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"external cassette, so is super low maintenance in terms of wear "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"and tear. All in all it's an impressive package for the price, "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"white"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike gives kids aged six years and older "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a durable and uberlight mountain bike for their first experience "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"on tracks and easy cruising through forests and fields. A set of "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ability. If you're after a budget option, this is one of the best "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"commuter_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike is a great option for anyone who just "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"from Shimano\u2019s, this is a bike which doesn\u2019t break the "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bank and delivers craved performance. It\u2019s for the rider "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"A real joy to ride, this bike got very high "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"scores in last years Bike of the year report. The carefully "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"Vittoria Zaffiro tires give balance and grip.It includes "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"conveniently placed thumb throttle. Put it all together and you "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_setbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kd">var</span> <span class="nx">inventory_json</span> <span class="p">=</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"inventory"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"mountain_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This is a mid-travel trail slayer that is a fantastic "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"mudguards and a rack too. This is the bike for the rider who wants "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"carbon"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"Redesigned for the 2020 model year, this bike "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"impressed our testers and is the best all-around trail bike we've "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ever tested. The Shimano gear system effectively does away with an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"external cassette, so is super low maintenance in terms of wear "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"and tear. All in all it's an impressive package for the price, "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"white"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike gives kids aged six years and older "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a durable and uberlight mountain bike for their first experience "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"on tracks and easy cruising through forests and fields. A set of "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ability. If you're after a budget option, this is one of the best "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"commuter_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike is a great option for anyone who just "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"from Shimano\u2019s, this is a bike which doesn\u2019t break the "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bank and delivers craved performance. It\u2019s for the rider "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"A real joy to ride, this bike got very high "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"scores in last years Bike of the year report. The carefully "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"Vittoria Zaffiro tires give balance and grip.It includes "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"conveniently placed thumb throttle. Put it all together and you "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGetWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONGetArgs</span><span class="p">{</span><span class="nx">Indent</span><span class="p">:</span> <span class="s">" "</span><span class="p">,</span> <span class="nx">Newline</span><span class="p">:</span> <span class="s">"\n"</span><span class="p">,</span> <span class="nx">Space</span><span class="p">:</span> <span class="s">" "</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// { </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "colors": [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "black", </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "silver" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getmtnbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..mountain_bikes[*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getmodels</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..model"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Salacia","Mimas","Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_get2mtnbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..mountain_bikes[0:2].model"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGetWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONGetArgs</span><span class="p">{</span><span class="nx">Indent</span><span class="p">:</span> <span class="s">" "</span><span class="p">,</span> <span class="nx">Newline</span><span class="p">:</span> <span class="s">"\n"</span><span class="p">,</span> <span class="nx">Space</span><span class="p">:</span> <span class="s">" "</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// { </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "colors": [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "black", </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "white" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ], </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "description": "Redesigned for the 2020 model year </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..[?(@.specs.material == 'alloy')].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Mimas","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter3</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Salacia","Mimas","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter4</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatebikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1475,3941,1920,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1375,3841,1820,1972,3164] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1475,3941,1920,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatefilters1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mi">1500</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1500,3941,1500,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatefilters2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"pink\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [3 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..[*].colors"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["black","silver","pink"],["black","silver","pink"],["black","white"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_json_tutorial-stepget2mtnbikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_json_tutorial-stepget2mtnbikes" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/json_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_json_tutorial-stepget2mtnbikes" name="json_tutorial-stepget2mtnbikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_json_tutorial-stepget2mtnbikes" title="Open example"> C# </label> <div aria-labelledby="tab-json_tutorial-stepget2mtnbikes" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_json_tutorial-stepget2mtnbikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.RedisStackCommands</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">Json_tutorial</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\"Hyperion\""</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">JsonType</span><span class="p">[]</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Type</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res3</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; STRING</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_get' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">StrLen</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res4</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 8</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">StrAppend</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">" (Enduro bikes)"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res5</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 23</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'str' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">0</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1.5</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2.5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="p">-</span><span class="m">0.75</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1.75</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'num' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="k">new</span> <span class="kt">object?</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="k">new</span> <span class="p">{</span> <span class="n">crashes</span> <span class="p">=</span> <span class="m">0</span> <span class="p">},</span> <span class="k">null</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$[1].crashes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res13</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [0]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Del</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$.[-1]"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res14</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res15</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="k">new</span> <span class="kt">object</span><span class="p">[]</span> <span class="p">{</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res16</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrAppend</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res17</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res18</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrInsert</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res19</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res20</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem","Prickett","Royce","Castilla"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrTrim</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res21</span><span class="p">));</span> <span class="c1">// 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res22</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span><span class="p">[]</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrPop</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="p">(</span><span class="kt">object</span><span class="p">[])</span><span class="n">res23</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "Prickett"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span><span class="p">[]</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrPop</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="p">(</span><span class="kt">object</span><span class="p">[])</span><span class="n">res24</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; &lt;Empty string&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="p">{</span> <span class="n">model</span> <span class="p">=</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Ergonom"</span><span class="p">,</span> <span class="n">price</span> <span class="p">=</span> <span class="m">4972</span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res25</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ObjLen</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res26</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">IEnumerable</span><span class="p">&lt;</span><span class="n">HashSet</span><span class="p">&lt;</span><span class="kt">string</span><span class="p">&gt;&gt;</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ObjKeys</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res27</span><span class="p">.</span><span class="n">Select</span><span class="p">(</span><span class="n">b</span> <span class="p">=&gt;</span> <span class="s">$"{string.Join("</span><span class="p">,</span> <span class="s">", b.Select(c =&gt; $"</span><span class="p">{</span><span class="n">c</span><span class="p">}</span><span class="s">"))}"</span><span class="p">))</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> <span class="c1">// &gt;&gt;&gt; model, brand, price</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'obj' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">string</span> <span class="n">inventoryJson</span> <span class="p">=</span> <span class="s">@" </span></span></span><span class="line"><span class="cl"><span class="s">{ </span></span></span><span class="line"><span class="cl"><span class="s"> ""inventory"": { </span></span></span><span class="line"><span class="cl"><span class="s"> ""mountain_bikes"": [ </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:1"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Phoebe"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there\u2019s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 1920, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""carbon"", ""weight"": 13.1}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""silver""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:2"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Quaoar"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and tear. All in all it's an impressive package for the price, making it very competitive."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 2072, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""aluminium"", ""weight"": 7.9}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""white""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:3"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Weywot"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 3264, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""alloy"", ""weight"": 13.8} </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s"> ], </span></span></span><span class="line"><span class="cl"><span class="s"> ""commuter_bikes"": [ </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:4"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Salacia"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, this is a bike which doesn\u2019t break the bank and delivers craved performance. It\u2019s for the rider who wants both efficiency and capability."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 1475, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""aluminium"", ""weight"": 16.6}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""silver""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:5"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Mimas"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 3941, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""alloy"", ""weight"": 11.6} </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s"> ] </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s">}"</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">inventoryJson</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res28</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.*"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; {[[{"id":"bike:1","model":"Phoebe", ...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res30</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res32</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res32</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_mtnbikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res33</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res33</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot","Salacia","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_models' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res34</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[0:2].model"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res34</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get2mtnbikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res35</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res35</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [{"id":"bike:2","model":"Quaoar","description":"Redesigned for the 2020 model year...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter1' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res36</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[?(@.specs.material == 'alloy')].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res36</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Weywot","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res37</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res37</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot","Salacia","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter3' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res38</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res38</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res39</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res39</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res40</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res40</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res41</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res41</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter4' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res42</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..price"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res42</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res43</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="p">-</span><span class="m">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res43</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1820, 1972, 3164, 1375, 3841</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res44</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res44</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1920, 2072, 3264, 1475, 3941</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res45</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">1500</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res45</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res46</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..price"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res46</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [1500,2072,3264,1500,3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters1' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res47</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrAppend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s">"pink"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res47</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 3, 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res48</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[*].colors"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res48</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["black","silver","pink"],["black","white"],["black","silver","pink"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_json_tutorial-stepget2mtnbikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_json_tutorial-stepget2mtnbikes" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/Json_tutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> Filter expressions <code> ?() </code> let you select JSON elements based on certain conditions. You can use comparison operators ( <code> == </code> , <code> != </code> , <code> &lt; </code> , <code> &lt;= </code> , <code> &gt; </code> , <code> &gt;= </code> , and starting with version v2.4.2, also <code> =~ </code> ), logical operators ( <code> &amp;&amp; </code> , <code> || </code> ), and parenthesis ( <code> ( </code> , <code> ) </code> ) within these expressions. A filter expression can be applied on an array or on an object, iterating over all the <strong> elements </strong> in the array or all the <strong> values </strong> in the object, retrieving only the ones that match the filter condition. </p> <p> Paths within the filter condition use the dot notation with either <code> @ </code> to denote the current array element or the current object value, or <code> $ </code> to denote the top-level element. For example, use <code> @.key_name </code> to refer to a nested value and <code> $.top_level_key_name </code> to refer to a top-level value. </p> <p> From version v2.4.2 onward, you can use the comparison operator <code> =~ </code> to match a path of a string value on the left side against a regular expression pattern on the right side. For more information, see the <a href="https://docs.rs/regex/latest/regex/#syntax"> supported regular expression syntax docs </a> . </p> <p> Non-string values do not match. A match can only occur when the left side is a path of a string value and the right side is either a hard-coded string, or a path of a string value. See <a href="#json-filter-examples"> examples </a> below. </p> <p> The regex match is partial, meaning a regex pattern like <code> "foo" </code> matches a string such as <code> "barefoots" </code> . To make the match exact, use the regex pattern <code> "^foo$" </code> . </p> <p> Other JSONPath engines may use regex patterns between slashes (for example, <code> /foo/ </code> ), and their match is exact. They can perform partial matches using a regex pattern such as <code> /.*foo.*/ </code> . </p> <h3 id="filter-examples"> Filter examples </h3> <p> In the following example, the filter only returns mountain bikes with a price less than 3000 and a weight less than 10: </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="json_tutorial-stepfilter1"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_json_tutorial-stepfilter1" name="json_tutorial-stepfilter1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_json_tutorial-stepfilter1" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-json_tutorial-stepfilter1" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_json_tutorial-stepfilter1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; JSON.GET bikes:inventory '$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]' </span></span><span class="line hl"><span class="cl">"[{\"id\":\"bike:2\",\"model\":\"Quaoar\",\"description\":\"Redesigned for the 2020 model year...</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_json_tutorial-stepfilter1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_json_tutorial-stepfilter1" name="json_tutorial-stepfilter1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_json_tutorial-stepfilter1" title="Open example"> Python </label> <div aria-labelledby="tab-json_tutorial-stepfilter1" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_json_tutorial-stepfilter1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for JSON doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/json/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s1">'"Hyperion"'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Hyperion"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['string']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">strlen</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [10]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">strappend</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s1">'" (Enduro bikes)"'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 27</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Hyperion"" (Enduro bikes)"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [2.5]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1.75]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"Deimos"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"crashes"</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span> <span class="kc">None</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['["Deimos", { "crashes": 0 }, null]']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$[1].crashes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['0']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$.[-1]"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Deimos', {'crashes': 0}]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrappend</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s2">"Norem"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Norem']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrinsert</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">,</span> <span class="s2">"Royce"</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [4]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Norem', 'Prickett', 'Royce', 'Castilla']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrtrim</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res21</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res22</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res22</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Prickett']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res23</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrpop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res23</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Prickett"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res24</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrpop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res24</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [None]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res25</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Deimos"</span><span class="p">,</span> <span class="s2">"brand"</span><span class="p">:</span> <span class="s2">"Ergonom"</span><span class="p">,</span> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">4972</span><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res25</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res26</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">objlen</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res26</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [3]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">objkeys</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['model', 'brand', 'price']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">inventory_json</span> <span class="o">=</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"inventory"</span><span class="p">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mountain_bikes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This is a mid-travel trail slayer that is a fantastic "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"gives plenty of gear range to tackle hills and there</span><span class="se">\u2019</span><span class="s2">s room for "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mudguards and a rack too. This is the bike for the rider who wants "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"carbon"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"Redesigned for the 2020 model year, this bike "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"impressed our testers and is the best all-around trail bike we've "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"ever tested. The Shimano gear system effectively does away with an "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"external cassette, so is super low maintenance in terms of wear "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"and tear. All in all it's an impressive package for the price, "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"white"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This bike gives kids aged six years and older "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"a durable and uberlight mountain bike for their first experience "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"on tracks and easy cruising through forests and fields. A set of "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"ability. If you're after a budget option, this is one of the best "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"alloy"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="s2">"commuter_bikes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This bike is a great option for anyone who just "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"wants a bike to get about on With a slick-shifting Claris gears "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"from Shimano</span><span class="se">\u2019</span><span class="s2">s, this is a bike which doesn</span><span class="se">\u2019</span><span class="s2">t break the "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bank and delivers craved performance. It</span><span class="se">\u2019</span><span class="s2">s for the rider "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"A real joy to ride, this bike got very high "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"scores in last years Bike of the year report. The carefully "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"Vittoria Zaffiro tires give balance and grip.It includes "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"conveniently placed thumb throttle. Put it all together and you "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"alloy"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="n">inventory_json</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; [[{'id': 'bike:1', 'model': 'Phoebe',</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 'description': 'This is a mid-travel trail slayer...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[*].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s1">'$.inventory["mountain_bikes"][*].model'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..mountain_bikes[*].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot', 'Salacia', 'Mimas']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..mountain_bikes[0:2].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="c1"># &gt;&gt;&gt; [{'id': 'bike:2', 'model': 'Quaoar',</span> </span></span><span class="line hl"><span class="cl"><span class="c1"># 'description': "Redesigned for the 2020 model year...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[?(@.specs.material == 'alloy')].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Weywot', 'Mimas']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Quaoar', 'Weywot', 'Salacia', 'Mimas']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Quaoar', 'Weywot']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1920, 2072, 3264, 1475, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1820, 1972, 3164, 1375, 3841]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1920, 2072, 3264, 1475, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> <span class="mi">1500</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1500, 2072, 3264, 1500, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrappend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s2">"pink"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [3, 3]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[*].colors"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="n">res21</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['black', 'silver', 'pink'], ['black', 'white'], ['black', 'silver', 'pink']]</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_json_tutorial-stepfilter1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_json_tutorial-stepfilter1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_json.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_json_tutorial-stepfilter1" name="json_tutorial-stepfilter1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_json_tutorial-stepfilter1" title="Open example"> Node.js </label> <div aria-labelledby="tab-json_tutorial-stepfilter1" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_json_tutorial-stepfilter1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">createClient</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s1">'"Hyperion"'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// "Hyperion" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// [ 'string' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">strLen</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// [10] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">strAppend</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s1">'" (Enduro bikes)"'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// 27 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// ['"Hyperion"" (Enduro bikes)"'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"Deimos"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"crashes"</span><span class="o">:</span> <span class="mi">0</span> <span class="p">},</span> <span class="kc">null</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 }, null ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$[1].crashes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 }, null ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$.[-1]"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 } ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrAppend</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s2">"Norem"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">);</span> <span class="c1">// [ 'Norem' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrInsert</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">,</span> <span class="s2">"Royse"</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">);</span> <span class="c1">// [4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">);</span> <span class="c1">// [ 'Norem', 'Prickett', 'Royse', 'Castilla' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrTrim</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">);</span> <span class="c1">// [ 'Prickett' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res23</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrPop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res23</span><span class="p">);</span> <span class="c1">// [ 'Prickett' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res24</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrPop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res24</span><span class="p">);</span> <span class="c1">// [null] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res25</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"brand"</span><span class="o">:</span> <span class="s2">"Ergonom"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">4972</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res25</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res26</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">objLen</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res26</span><span class="p">);</span> <span class="c1">// [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">objKeys</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27</span><span class="p">);</span> <span class="c1">// [['model', 'brand', 'price']] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">inventoryJSON</span> <span class="o">=</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"inventory"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mountain_bikes"</span><span class="o">:</span> <span class="p">[{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there\u2019s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"carbon"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">13.1</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">7.9</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"white"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"alloy"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">13.8</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="s2">"commuter_bikes"</span><span class="o">:</span> <span class="p">[{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, this is a bike which doesn\u2019t break the bank and delivers craved performance. It\u2019s for the rider who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">16.6</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"alloy"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">11.6</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">};</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="nx">inventoryJSON</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$.inventory.*"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="cm">/* </span></span></span><span class="line"><span class="cl"><span class="cm">[ </span></span></span><span class="line"><span class="cl"><span class="cm"> [ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:1', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Phoebe', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there’s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 1920, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:2', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Quaoar', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 2072, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:3', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Weywot', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 3264, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm"> ], </span></span></span><span class="line"><span class="cl"><span class="cm"> [ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:4', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Salacia', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano’s, this is a bike which doesn’t break the bank and delivers craved performance. It’s for the rider who wants both efficiency and capability.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 1475, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:5', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Mimas', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 3941, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm"> ] </span></span></span><span class="line"><span class="cl"><span class="cm">] </span></span></span><span class="line"><span class="cl"><span class="cm">*/</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res30</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$.inventory.mountain_bikes[*].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res30</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res31</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s1">'$.inventory["mountain_bikes"][*].model'</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res31</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res32</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[*].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res32</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res33</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res33</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot', 'Salacia', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res34</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[0:2].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res34</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res35</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span> </span></span><span class="line hl"><span class="cl"><span class="p">});</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res35</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="cm">/* </span></span></span><span class="line hl"><span class="cl"><span class="cm">[ </span></span></span><span class="line hl"><span class="cl"><span class="cm"> { </span></span></span><span class="line hl"><span class="cl"><span class="cm"> id: 'bike:2', </span></span></span><span class="line hl"><span class="cl"><span class="cm"> model: 'Quaoar', </span></span></span><span class="line hl"><span class="cl"><span class="cm"> description: "Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive.", </span></span></span><span class="line hl"><span class="cl"><span class="cm"> price: 2072, </span></span></span><span class="line hl"><span class="cl"><span class="cm"> specs: { material: 'aluminium', weight: 7.9 }, </span></span></span><span class="line hl"><span class="cl"><span class="cm"> colors: [ 'black', 'white' ] </span></span></span><span class="line hl"><span class="cl"><span class="cm"> } </span></span></span><span class="line hl"><span class="cl"><span class="cm">] </span></span></span><span class="line hl"><span class="cl"><span class="cm">*/</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1">// names of bikes made from an alloy </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res36</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[?(@.specs.material == 'alloy')].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// ['Weywot', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[?(@.specs.material =~ '(?i)al')].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37</span><span class="p">);</span> <span class="c1">// ['Quaoar', 'Weywot', 'Salacia', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37a</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[0].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37b</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[1].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37c</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[2].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37d</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37d</span><span class="p">);</span> <span class="c1">// ['Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res38</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..price"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res38</span><span class="p">);</span> <span class="c1">// [1920, 2072, 3264, 1475, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res39</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res39</span><span class="p">);</span> <span class="c1">// [1820, 1972, 3164, 1375, 3841] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40</span><span class="p">);</span> <span class="c1">// [1920, 2072, 3264, 1475, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40a</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.*[?(@.price&lt;2000)].price'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mi">1500</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1">// Get all prices from the inventory </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res40b</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$..price'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40b</span><span class="p">);</span> <span class="c1">// [1500, 2072, 3264, 1500, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res41</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrAppend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s2">"pink"</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res41</span><span class="p">);</span> <span class="c1">// [3, 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res42</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[*].colors"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res42</span><span class="p">);</span> <span class="c1">// [['black', 'silver', 'pink'], ['black', 'white'], ['black', 'silver', 'pink']] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_json_tutorial-stepfilter1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_json_tutorial-stepfilter1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-json.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_json_tutorial-stepfilter1" name="json_tutorial-stepfilter1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_json_tutorial-stepfilter1" title="Open example"> Java </label> <div aria-labelledby="tab-json_tutorial-stepfilter1" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_json_tutorial-stepfilter1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.json.Path2</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.json.JSONArray</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.json.JSONObject</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">JsonExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">"\"Hyperion\""</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Class</span><span class="o">&lt;?&gt;&gt;</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonType</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [class java.lang.String] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_get' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonStrLen</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [8] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonStrAppend</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">" (Enduro bikes)"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [23] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'str' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">0</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mf">1.5</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="o">-</span><span class="mf">0.75</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'num' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">JSONArray</span><span class="o">()</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"Deimos"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="k">new</span> <span class="n">JSONObject</span><span class="o">().</span><span class="na">put</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="mi">0</span><span class="o">))</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">((</span><span class="n">Object</span><span class="o">)</span> <span class="kc">null</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$[1].crashes"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [0] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonDel</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.[-1]"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="k">new</span> <span class="n">JSONArray</span><span class="o">());</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrAppendWithEscape</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">"Norem"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrInsertWithEscape</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">,</span> <span class="s">"Prickett"</span><span class="o">,</span> <span class="s">"Royce"</span><span class="o">,</span> <span class="s">"Castilla"</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res19</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["Norem","Prickett","Royce","Castilla"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrTrim</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">,</span> <span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res23</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrPop</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res23</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [Prickett] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res24</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrPop</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res24</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [null] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res25</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">JSONObject</span><span class="o">()</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"model"</span><span class="o">,</span> <span class="s">"Deimos"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"brand"</span><span class="o">,</span> <span class="s">"Ergonom"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"price"</span><span class="o">,</span> <span class="mi">4972</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res25</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res26</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonObjLen</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res26</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;&gt;</span> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonObjKeys</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [[price, model, brand]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'obj' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">inventory_json</span> <span class="o">=</span> <span class="s">"{"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"inventory\": {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"mountain_bikes\": ["</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:1\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Phoebe\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This is a mid-travel trail slayer that is a "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for mudguards "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and a rack too. This is the bike for the rider who wants trail manners with "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"low fuss ownership.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1920,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"carbon\", \"weight\": 13.1},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"silver\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:2\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Quaoar\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"Redesigned for the 2020 model year, this "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"bike impressed our testers and is the best all-around trail bike we've ever "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"tested. The Shimano gear system effectively does away with an external cassette, "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"so is super low maintenance in terms of wear and tear. All in all it's an "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"impressive package for the price, making it very competitive.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 2072,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"aluminium\", \"weight\": 7.9},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"white\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:3\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Weywot\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This bike gives kids aged six years and older "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"a durable and uberlight mountain bike for their first experience on tracks and easy "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"provide ample stopping ability. If you're after a budget option, this is one of the "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"best bikes you could get.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3264,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"alloy\", \"weight\": 13.8}"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" ],"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"commuter_bikes\": ["</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:4\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Salacia\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This bike is a great option for anyone who just "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"this is a bike which doesn\u2019t break the bank and delivers craved performance. "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"It\u2019s for the rider who wants both efficiency and capability.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1475,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"aluminium\", \"weight\": 16.6},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"silver\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:5\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Mimas\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"A real joy to ride, this bike got very high scores "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"in last years Bike of the year report. The carefully crafted 50-34 tooth chainset "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"throttle. Put it all together and you get a bike that helps redefine what can be "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"done for this price.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3941,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"alloy\", \"weight\": 11.6}"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" ]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"}"</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="n">inventory_json</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res28</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [[{"specs":{"material":"carbon","weight":13.1},"price":1920, ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res30</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res30</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res31</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res31</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res32</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res32</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_mtnbikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res33</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..model"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res33</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot","Salacia","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_models' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res34</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[0:2].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res34</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get2mtnbikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">Object</span> <span class="n">res35</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> </span></span><span class="line hl"><span class="cl"> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="o">)</span> </span></span><span class="line hl"><span class="cl"> <span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res35</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [{"specs":{"material":"aluminium","weight":7.9},"price":2072,... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter1' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res36</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[?(@.specs.material == 'alloy')].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Weywot","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res37</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res37</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot","Salacia","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter3' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res38</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res38</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter4' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res39</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res39</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res40</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">),</span> <span class="o">-</span><span class="mi">100</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res40</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1820,1972,3164,1375,3841] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res41</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">),</span> <span class="mi">100</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res41</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="o">),</span> <span class="mi">1500</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res42</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res42</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1500,2072,3264,1500,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters1' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res43</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrAppendWithEscape</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"pink\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res43</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [3, 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res44</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[*].colors"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res44</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["black","silver","\"pink\""],["black","white"],["black","silver","\"pink\""]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">close</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_json_tutorial-stepfilter1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_json_tutorial-stepfilter1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/JsonExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_json_tutorial-stepfilter1" name="json_tutorial-stepfilter1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_json_tutorial-stepfilter1" title="Open example"> Go </label> <div aria-labelledby="tab-json_tutorial-stepfilter1" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_json_tutorial-stepfilter1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_setget</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Hyperion\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONType</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [[string]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_str</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Hyperion\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONStrLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res4</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 8 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONStrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\" (Enduro bikes)\""</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res5</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 23 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_num</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_arr</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"crashes"</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kc">nil</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$[1].crashes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [0] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONDel</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$.[-1]"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_arr2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{}).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\"Norem\""</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrInsert</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Prickett\""</span><span class="p">,</span> <span class="s">"\"Royce\""</span><span class="p">,</span> <span class="s">"\"Castilla\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Norem", "Prickett", "Royce", "Castilla"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">rangeStop</span> <span class="o">:=</span> <span class="mi">1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrTrimWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONArrTrimArgs</span><span class="p">{</span><span class="nx">Start</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">Stop</span><span class="p">:</span> <span class="o">&amp;</span><span class="nx">rangeStop</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res23</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res23</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res24</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res24</span><span class="p">)</span> <span class="c1">// [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_obj</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res25</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"brand"</span><span class="p">:</span> <span class="s">"Ergonom"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">4972</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res25</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res26</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONObjLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res26</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res27</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONObjKeys</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res27</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [brand model price] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">var</span> <span class="nx">inventory_json</span> <span class="p">=</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"inventory"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"mountain_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This is a mid-travel trail slayer that is a fantastic "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"mudguards and a rack too. This is the bike for the rider who wants "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"carbon"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"Redesigned for the 2020 model year, this bike "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"impressed our testers and is the best all-around trail bike we've "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ever tested. The Shimano gear system effectively does away with an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"external cassette, so is super low maintenance in terms of wear "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"and tear. All in all it's an impressive package for the price, "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"white"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike gives kids aged six years and older "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a durable and uberlight mountain bike for their first experience "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"on tracks and easy cruising through forests and fields. A set of "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ability. If you're after a budget option, this is one of the best "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"commuter_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike is a great option for anyone who just "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"from Shimano\u2019s, this is a bike which doesn\u2019t break the "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bank and delivers craved performance. It\u2019s for the rider "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"A real joy to ride, this bike got very high "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"scores in last years Bike of the year report. The carefully "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"Vittoria Zaffiro tires give balance and grip.It includes "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"conveniently placed thumb throttle. Put it all together and you "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_setbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kd">var</span> <span class="nx">inventory_json</span> <span class="p">=</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"inventory"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"mountain_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This is a mid-travel trail slayer that is a fantastic "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"mudguards and a rack too. This is the bike for the rider who wants "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"carbon"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"Redesigned for the 2020 model year, this bike "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"impressed our testers and is the best all-around trail bike we've "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ever tested. The Shimano gear system effectively does away with an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"external cassette, so is super low maintenance in terms of wear "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"and tear. All in all it's an impressive package for the price, "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"white"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike gives kids aged six years and older "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a durable and uberlight mountain bike for their first experience "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"on tracks and easy cruising through forests and fields. A set of "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ability. If you're after a budget option, this is one of the best "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"commuter_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike is a great option for anyone who just "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"from Shimano\u2019s, this is a bike which doesn\u2019t break the "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bank and delivers craved performance. It\u2019s for the rider "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"A real joy to ride, this bike got very high "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"scores in last years Bike of the year report. The carefully "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"Vittoria Zaffiro tires give balance and grip.It includes "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"conveniently placed thumb throttle. Put it all together and you "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGetWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONGetArgs</span><span class="p">{</span><span class="nx">Indent</span><span class="p">:</span> <span class="s">" "</span><span class="p">,</span> <span class="nx">Newline</span><span class="p">:</span> <span class="s">"\n"</span><span class="p">,</span> <span class="nx">Space</span><span class="p">:</span> <span class="s">" "</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// { </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "colors": [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "black", </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "silver" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getmtnbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..mountain_bikes[*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getmodels</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..model"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Salacia","Mimas","Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_get2mtnbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..mountain_bikes[0:2].model"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGetWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONGetArgs</span><span class="p">{</span><span class="nx">Indent</span><span class="p">:</span> <span class="s">" "</span><span class="p">,</span> <span class="nx">Newline</span><span class="p">:</span> <span class="s">"\n"</span><span class="p">,</span> <span class="nx">Space</span><span class="p">:</span> <span class="s">" "</span><span class="p">},</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="c1">// &gt;&gt;&gt; </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="c1">// { </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="c1">// "colors": [ </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="c1">// "black", </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="c1">// "white" </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="c1">// ], </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="c1">// "description": "Redesigned for the 2020 model year </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="c1">// ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..[?(@.specs.material == 'alloy')].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Mimas","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter3</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Salacia","Mimas","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter4</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatebikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1475,3941,1920,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1375,3841,1820,1972,3164] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1475,3941,1920,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatefilters1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mi">1500</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1500,3941,1500,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatefilters2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"pink\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [3 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..[*].colors"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["black","silver","pink"],["black","silver","pink"],["black","white"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_json_tutorial-stepfilter1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_json_tutorial-stepfilter1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/json_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_json_tutorial-stepfilter1" name="json_tutorial-stepfilter1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_json_tutorial-stepfilter1" title="Open example"> C# </label> <div aria-labelledby="tab-json_tutorial-stepfilter1" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_json_tutorial-stepfilter1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.RedisStackCommands</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">Json_tutorial</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\"Hyperion\""</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">JsonType</span><span class="p">[]</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Type</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res3</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; STRING</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_get' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">StrLen</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res4</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 8</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">StrAppend</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">" (Enduro bikes)"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res5</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 23</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'str' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">0</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1.5</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2.5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="p">-</span><span class="m">0.75</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1.75</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'num' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="k">new</span> <span class="kt">object?</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="k">new</span> <span class="p">{</span> <span class="n">crashes</span> <span class="p">=</span> <span class="m">0</span> <span class="p">},</span> <span class="k">null</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$[1].crashes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res13</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [0]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Del</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$.[-1]"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res14</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res15</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="k">new</span> <span class="kt">object</span><span class="p">[]</span> <span class="p">{</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res16</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrAppend</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res17</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res18</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrInsert</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res19</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res20</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem","Prickett","Royce","Castilla"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrTrim</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res21</span><span class="p">));</span> <span class="c1">// 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res22</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span><span class="p">[]</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrPop</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="p">(</span><span class="kt">object</span><span class="p">[])</span><span class="n">res23</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "Prickett"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span><span class="p">[]</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrPop</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="p">(</span><span class="kt">object</span><span class="p">[])</span><span class="n">res24</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; &lt;Empty string&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="p">{</span> <span class="n">model</span> <span class="p">=</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Ergonom"</span><span class="p">,</span> <span class="n">price</span> <span class="p">=</span> <span class="m">4972</span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res25</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ObjLen</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res26</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">IEnumerable</span><span class="p">&lt;</span><span class="n">HashSet</span><span class="p">&lt;</span><span class="kt">string</span><span class="p">&gt;&gt;</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ObjKeys</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res27</span><span class="p">.</span><span class="n">Select</span><span class="p">(</span><span class="n">b</span> <span class="p">=&gt;</span> <span class="s">$"{string.Join("</span><span class="p">,</span> <span class="s">", b.Select(c =&gt; $"</span><span class="p">{</span><span class="n">c</span><span class="p">}</span><span class="s">"))}"</span><span class="p">))</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> <span class="c1">// &gt;&gt;&gt; model, brand, price</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'obj' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">string</span> <span class="n">inventoryJson</span> <span class="p">=</span> <span class="s">@" </span></span></span><span class="line"><span class="cl"><span class="s">{ </span></span></span><span class="line"><span class="cl"><span class="s"> ""inventory"": { </span></span></span><span class="line"><span class="cl"><span class="s"> ""mountain_bikes"": [ </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:1"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Phoebe"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there\u2019s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 1920, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""carbon"", ""weight"": 13.1}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""silver""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:2"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Quaoar"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and tear. All in all it's an impressive package for the price, making it very competitive."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 2072, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""aluminium"", ""weight"": 7.9}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""white""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:3"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Weywot"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 3264, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""alloy"", ""weight"": 13.8} </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s"> ], </span></span></span><span class="line"><span class="cl"><span class="s"> ""commuter_bikes"": [ </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:4"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Salacia"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, this is a bike which doesn\u2019t break the bank and delivers craved performance. It\u2019s for the rider who wants both efficiency and capability."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 1475, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""aluminium"", ""weight"": 16.6}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""silver""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:5"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Mimas"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 3941, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""alloy"", ""weight"": 11.6} </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s"> ] </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s">}"</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">inventoryJson</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res28</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.*"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; {[[{"id":"bike:1","model":"Phoebe", ...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res30</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res32</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res32</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_mtnbikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res33</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res33</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot","Salacia","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_models' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res34</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[0:2].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res34</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get2mtnbikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res35</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span> </span></span><span class="line hl"><span class="cl"> <span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res35</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [{"id":"bike:2","model":"Quaoar","description":"Redesigned for the 2020 model year...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter1' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res36</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[?(@.specs.material == 'alloy')].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res36</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Weywot","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res37</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res37</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot","Salacia","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter3' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res38</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res38</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res39</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res39</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res40</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res40</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res41</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res41</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter4' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res42</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..price"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res42</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res43</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="p">-</span><span class="m">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res43</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1820, 1972, 3164, 1375, 3841</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res44</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res44</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1920, 2072, 3264, 1475, 3941</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res45</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">1500</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res45</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res46</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..price"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res46</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [1500,2072,3264,1500,3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters1' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res47</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrAppend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s">"pink"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res47</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 3, 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res48</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[*].colors"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res48</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["black","silver","pink"],["black","white"],["black","silver","pink"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_json_tutorial-stepfilter1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_json_tutorial-stepfilter1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/Json_tutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> This example filters the inventory for the model names of bikes made from alloy: </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="json_tutorial-stepfilter2"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_json_tutorial-stepfilter2" name="json_tutorial-stepfilter2" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_json_tutorial-stepfilter2" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-json_tutorial-stepfilter2" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_json_tutorial-stepfilter2" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; JSON.GET bikes:inventory '$..[?(@.specs.material == "alloy")].model' </span></span><span class="line hl"><span class="cl">"[\"Weywot\",\"Mimas\"]"</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_json_tutorial-stepfilter2')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_json_tutorial-stepfilter2" name="json_tutorial-stepfilter2" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_json_tutorial-stepfilter2" title="Open example"> Python </label> <div aria-labelledby="tab-json_tutorial-stepfilter2" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_json_tutorial-stepfilter2" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for JSON doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/json/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s1">'"Hyperion"'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Hyperion"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['string']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">strlen</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [10]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">strappend</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s1">'" (Enduro bikes)"'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 27</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Hyperion"" (Enduro bikes)"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [2.5]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1.75]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"Deimos"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"crashes"</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span> <span class="kc">None</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['["Deimos", { "crashes": 0 }, null]']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$[1].crashes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['0']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$.[-1]"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Deimos', {'crashes': 0}]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrappend</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s2">"Norem"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Norem']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrinsert</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">,</span> <span class="s2">"Royce"</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [4]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Norem', 'Prickett', 'Royce', 'Castilla']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrtrim</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res21</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res22</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res22</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Prickett']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res23</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrpop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res23</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Prickett"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res24</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrpop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res24</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [None]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res25</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Deimos"</span><span class="p">,</span> <span class="s2">"brand"</span><span class="p">:</span> <span class="s2">"Ergonom"</span><span class="p">,</span> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">4972</span><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res25</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res26</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">objlen</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res26</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [3]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">objkeys</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['model', 'brand', 'price']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">inventory_json</span> <span class="o">=</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"inventory"</span><span class="p">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mountain_bikes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This is a mid-travel trail slayer that is a fantastic "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"gives plenty of gear range to tackle hills and there</span><span class="se">\u2019</span><span class="s2">s room for "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mudguards and a rack too. This is the bike for the rider who wants "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"carbon"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"Redesigned for the 2020 model year, this bike "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"impressed our testers and is the best all-around trail bike we've "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"ever tested. The Shimano gear system effectively does away with an "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"external cassette, so is super low maintenance in terms of wear "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"and tear. All in all it's an impressive package for the price, "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"white"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This bike gives kids aged six years and older "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"a durable and uberlight mountain bike for their first experience "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"on tracks and easy cruising through forests and fields. A set of "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"ability. If you're after a budget option, this is one of the best "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"alloy"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="s2">"commuter_bikes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This bike is a great option for anyone who just "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"wants a bike to get about on With a slick-shifting Claris gears "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"from Shimano</span><span class="se">\u2019</span><span class="s2">s, this is a bike which doesn</span><span class="se">\u2019</span><span class="s2">t break the "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bank and delivers craved performance. It</span><span class="se">\u2019</span><span class="s2">s for the rider "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"A real joy to ride, this bike got very high "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"scores in last years Bike of the year report. The carefully "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"Vittoria Zaffiro tires give balance and grip.It includes "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"conveniently placed thumb throttle. Put it all together and you "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"alloy"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="n">inventory_json</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; [[{'id': 'bike:1', 'model': 'Phoebe',</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 'description': 'This is a mid-travel trail slayer...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[*].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s1">'$.inventory["mountain_bikes"][*].model'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..mountain_bikes[*].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot', 'Salacia', 'Mimas']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..mountain_bikes[0:2].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; [{'id': 'bike:2', 'model': 'Quaoar',</span> </span></span><span class="line"><span class="cl"><span class="c1"># 'description': "Redesigned for the 2020 model year...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[?(@.specs.material == 'alloy')].model"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Weywot', 'Mimas']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Quaoar', 'Weywot', 'Salacia', 'Mimas']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Quaoar', 'Weywot']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1920, 2072, 3264, 1475, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1820, 1972, 3164, 1375, 3841]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1920, 2072, 3264, 1475, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> <span class="mi">1500</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1500, 2072, 3264, 1500, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrappend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s2">"pink"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [3, 3]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[*].colors"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="n">res21</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['black', 'silver', 'pink'], ['black', 'white'], ['black', 'silver', 'pink']]</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_json_tutorial-stepfilter2')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_json_tutorial-stepfilter2" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_json.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_json_tutorial-stepfilter2" name="json_tutorial-stepfilter2" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_json_tutorial-stepfilter2" title="Open example"> Node.js </label> <div aria-labelledby="tab-json_tutorial-stepfilter2" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_json_tutorial-stepfilter2" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">createClient</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s1">'"Hyperion"'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// "Hyperion" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// [ 'string' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">strLen</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// [10] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">strAppend</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s1">'" (Enduro bikes)"'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// 27 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// ['"Hyperion"" (Enduro bikes)"'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"Deimos"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"crashes"</span><span class="o">:</span> <span class="mi">0</span> <span class="p">},</span> <span class="kc">null</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 }, null ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$[1].crashes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 }, null ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$.[-1]"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 } ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrAppend</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s2">"Norem"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">);</span> <span class="c1">// [ 'Norem' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrInsert</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">,</span> <span class="s2">"Royse"</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">);</span> <span class="c1">// [4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">);</span> <span class="c1">// [ 'Norem', 'Prickett', 'Royse', 'Castilla' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrTrim</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">);</span> <span class="c1">// [ 'Prickett' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res23</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrPop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res23</span><span class="p">);</span> <span class="c1">// [ 'Prickett' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res24</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrPop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res24</span><span class="p">);</span> <span class="c1">// [null] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res25</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"brand"</span><span class="o">:</span> <span class="s2">"Ergonom"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">4972</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res25</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res26</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">objLen</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res26</span><span class="p">);</span> <span class="c1">// [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">objKeys</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27</span><span class="p">);</span> <span class="c1">// [['model', 'brand', 'price']] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">inventoryJSON</span> <span class="o">=</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"inventory"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mountain_bikes"</span><span class="o">:</span> <span class="p">[{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there\u2019s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"carbon"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">13.1</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">7.9</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"white"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"alloy"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">13.8</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="s2">"commuter_bikes"</span><span class="o">:</span> <span class="p">[{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, this is a bike which doesn\u2019t break the bank and delivers craved performance. It\u2019s for the rider who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">16.6</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"alloy"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">11.6</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">};</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="nx">inventoryJSON</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$.inventory.*"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="cm">/* </span></span></span><span class="line"><span class="cl"><span class="cm">[ </span></span></span><span class="line"><span class="cl"><span class="cm"> [ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:1', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Phoebe', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there’s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 1920, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:2', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Quaoar', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 2072, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:3', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Weywot', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 3264, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm"> ], </span></span></span><span class="line"><span class="cl"><span class="cm"> [ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:4', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Salacia', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano’s, this is a bike which doesn’t break the bank and delivers craved performance. It’s for the rider who wants both efficiency and capability.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 1475, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:5', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Mimas', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 3941, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm"> ] </span></span></span><span class="line"><span class="cl"><span class="cm">] </span></span></span><span class="line"><span class="cl"><span class="cm">*/</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res30</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$.inventory.mountain_bikes[*].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res30</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res31</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s1">'$.inventory["mountain_bikes"][*].model'</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res31</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res32</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[*].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res32</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res33</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res33</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot', 'Salacia', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res34</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[0:2].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res34</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res35</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res35</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="cm">/* </span></span></span><span class="line"><span class="cl"><span class="cm">[ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:2', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Quaoar', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 2072, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: { material: 'aluminium', weight: 7.9 }, </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [ 'black', 'white' ] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm">] </span></span></span><span class="line"><span class="cl"><span class="cm">*/</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="c1">// names of bikes made from an alloy </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res36</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[?(@.specs.material == 'alloy')].model"</span> </span></span><span class="line hl"><span class="cl"><span class="p">});</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// ['Weywot', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[?(@.specs.material =~ '(?i)al')].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37</span><span class="p">);</span> <span class="c1">// ['Quaoar', 'Weywot', 'Salacia', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37a</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[0].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37b</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[1].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37c</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[2].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37d</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37d</span><span class="p">);</span> <span class="c1">// ['Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res38</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..price"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res38</span><span class="p">);</span> <span class="c1">// [1920, 2072, 3264, 1475, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res39</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res39</span><span class="p">);</span> <span class="c1">// [1820, 1972, 3164, 1375, 3841] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40</span><span class="p">);</span> <span class="c1">// [1920, 2072, 3264, 1475, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40a</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.*[?(@.price&lt;2000)].price'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mi">1500</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1">// Get all prices from the inventory </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res40b</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$..price'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40b</span><span class="p">);</span> <span class="c1">// [1500, 2072, 3264, 1500, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res41</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrAppend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s2">"pink"</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res41</span><span class="p">);</span> <span class="c1">// [3, 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res42</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[*].colors"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res42</span><span class="p">);</span> <span class="c1">// [['black', 'silver', 'pink'], ['black', 'white'], ['black', 'silver', 'pink']] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_json_tutorial-stepfilter2')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_json_tutorial-stepfilter2" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-json.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_json_tutorial-stepfilter2" name="json_tutorial-stepfilter2" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_json_tutorial-stepfilter2" title="Open example"> Java </label> <div aria-labelledby="tab-json_tutorial-stepfilter2" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_json_tutorial-stepfilter2" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.json.Path2</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.json.JSONArray</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.json.JSONObject</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">JsonExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">"\"Hyperion\""</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Class</span><span class="o">&lt;?&gt;&gt;</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonType</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [class java.lang.String] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_get' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonStrLen</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [8] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonStrAppend</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">" (Enduro bikes)"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [23] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'str' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">0</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mf">1.5</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="o">-</span><span class="mf">0.75</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'num' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">JSONArray</span><span class="o">()</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"Deimos"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="k">new</span> <span class="n">JSONObject</span><span class="o">().</span><span class="na">put</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="mi">0</span><span class="o">))</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">((</span><span class="n">Object</span><span class="o">)</span> <span class="kc">null</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$[1].crashes"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [0] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonDel</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.[-1]"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="k">new</span> <span class="n">JSONArray</span><span class="o">());</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrAppendWithEscape</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">"Norem"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrInsertWithEscape</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">,</span> <span class="s">"Prickett"</span><span class="o">,</span> <span class="s">"Royce"</span><span class="o">,</span> <span class="s">"Castilla"</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res19</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["Norem","Prickett","Royce","Castilla"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrTrim</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">,</span> <span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res23</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrPop</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res23</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [Prickett] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res24</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrPop</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res24</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [null] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res25</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">JSONObject</span><span class="o">()</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"model"</span><span class="o">,</span> <span class="s">"Deimos"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"brand"</span><span class="o">,</span> <span class="s">"Ergonom"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"price"</span><span class="o">,</span> <span class="mi">4972</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res25</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res26</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonObjLen</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res26</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;&gt;</span> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonObjKeys</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [[price, model, brand]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'obj' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">inventory_json</span> <span class="o">=</span> <span class="s">"{"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"inventory\": {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"mountain_bikes\": ["</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:1\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Phoebe\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This is a mid-travel trail slayer that is a "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for mudguards "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and a rack too. This is the bike for the rider who wants trail manners with "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"low fuss ownership.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1920,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"carbon\", \"weight\": 13.1},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"silver\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:2\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Quaoar\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"Redesigned for the 2020 model year, this "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"bike impressed our testers and is the best all-around trail bike we've ever "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"tested. The Shimano gear system effectively does away with an external cassette, "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"so is super low maintenance in terms of wear and tear. All in all it's an "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"impressive package for the price, making it very competitive.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 2072,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"aluminium\", \"weight\": 7.9},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"white\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:3\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Weywot\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This bike gives kids aged six years and older "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"a durable and uberlight mountain bike for their first experience on tracks and easy "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"provide ample stopping ability. If you're after a budget option, this is one of the "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"best bikes you could get.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3264,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"alloy\", \"weight\": 13.8}"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" ],"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"commuter_bikes\": ["</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:4\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Salacia\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This bike is a great option for anyone who just "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"this is a bike which doesn\u2019t break the bank and delivers craved performance. "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"It\u2019s for the rider who wants both efficiency and capability.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1475,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"aluminium\", \"weight\": 16.6},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"silver\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:5\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Mimas\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"A real joy to ride, this bike got very high scores "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"in last years Bike of the year report. The carefully crafted 50-34 tooth chainset "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"throttle. Put it all together and you get a bike that helps redefine what can be "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"done for this price.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3941,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"alloy\", \"weight\": 11.6}"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" ]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"}"</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="n">inventory_json</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res28</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [[{"specs":{"material":"carbon","weight":13.1},"price":1920, ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res30</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res30</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res31</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res31</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res32</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res32</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_mtnbikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res33</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..model"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res33</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot","Salacia","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_models' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res34</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[0:2].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res34</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get2mtnbikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res35</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res35</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [{"specs":{"material":"aluminium","weight":7.9},"price":2072,... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter1' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">Object</span> <span class="n">res36</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[?(@.specs.material == 'alloy')].model"</span><span class="o">)</span> </span></span><span class="line hl"><span class="cl"> <span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Weywot","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res37</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res37</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot","Salacia","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter3' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res38</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res38</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter4' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res39</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res39</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res40</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">),</span> <span class="o">-</span><span class="mi">100</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res40</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1820,1972,3164,1375,3841] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res41</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">),</span> <span class="mi">100</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res41</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="o">),</span> <span class="mi">1500</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res42</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res42</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1500,2072,3264,1500,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters1' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res43</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrAppendWithEscape</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"pink\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res43</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [3, 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res44</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[*].colors"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res44</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["black","silver","\"pink\""],["black","white"],["black","silver","\"pink\""]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">close</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_json_tutorial-stepfilter2')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_json_tutorial-stepfilter2" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/JsonExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_json_tutorial-stepfilter2" name="json_tutorial-stepfilter2" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_json_tutorial-stepfilter2" title="Open example"> Go </label> <div aria-labelledby="tab-json_tutorial-stepfilter2" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_json_tutorial-stepfilter2" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_setget</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Hyperion\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONType</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [[string]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_str</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Hyperion\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONStrLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res4</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 8 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONStrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\" (Enduro bikes)\""</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res5</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 23 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_num</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_arr</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"crashes"</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kc">nil</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$[1].crashes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [0] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONDel</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$.[-1]"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_arr2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{}).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\"Norem\""</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrInsert</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Prickett\""</span><span class="p">,</span> <span class="s">"\"Royce\""</span><span class="p">,</span> <span class="s">"\"Castilla\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Norem", "Prickett", "Royce", "Castilla"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">rangeStop</span> <span class="o">:=</span> <span class="mi">1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrTrimWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONArrTrimArgs</span><span class="p">{</span><span class="nx">Start</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">Stop</span><span class="p">:</span> <span class="o">&amp;</span><span class="nx">rangeStop</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res23</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res23</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res24</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res24</span><span class="p">)</span> <span class="c1">// [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_obj</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res25</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"brand"</span><span class="p">:</span> <span class="s">"Ergonom"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">4972</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res25</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res26</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONObjLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res26</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res27</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONObjKeys</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res27</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [brand model price] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">var</span> <span class="nx">inventory_json</span> <span class="p">=</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"inventory"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"mountain_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This is a mid-travel trail slayer that is a fantastic "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"mudguards and a rack too. This is the bike for the rider who wants "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"carbon"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"Redesigned for the 2020 model year, this bike "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"impressed our testers and is the best all-around trail bike we've "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ever tested. The Shimano gear system effectively does away with an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"external cassette, so is super low maintenance in terms of wear "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"and tear. All in all it's an impressive package for the price, "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"white"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike gives kids aged six years and older "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a durable and uberlight mountain bike for their first experience "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"on tracks and easy cruising through forests and fields. A set of "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ability. If you're after a budget option, this is one of the best "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"commuter_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike is a great option for anyone who just "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"from Shimano\u2019s, this is a bike which doesn\u2019t break the "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bank and delivers craved performance. It\u2019s for the rider "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"A real joy to ride, this bike got very high "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"scores in last years Bike of the year report. The carefully "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"Vittoria Zaffiro tires give balance and grip.It includes "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"conveniently placed thumb throttle. Put it all together and you "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_setbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kd">var</span> <span class="nx">inventory_json</span> <span class="p">=</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"inventory"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"mountain_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This is a mid-travel trail slayer that is a fantastic "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"mudguards and a rack too. This is the bike for the rider who wants "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"carbon"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"Redesigned for the 2020 model year, this bike "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"impressed our testers and is the best all-around trail bike we've "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ever tested. The Shimano gear system effectively does away with an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"external cassette, so is super low maintenance in terms of wear "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"and tear. All in all it's an impressive package for the price, "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"white"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike gives kids aged six years and older "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a durable and uberlight mountain bike for their first experience "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"on tracks and easy cruising through forests and fields. A set of "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ability. If you're after a budget option, this is one of the best "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"commuter_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike is a great option for anyone who just "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"from Shimano\u2019s, this is a bike which doesn\u2019t break the "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bank and delivers craved performance. It\u2019s for the rider "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"A real joy to ride, this bike got very high "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"scores in last years Bike of the year report. The carefully "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"Vittoria Zaffiro tires give balance and grip.It includes "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"conveniently placed thumb throttle. Put it all together and you "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGetWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONGetArgs</span><span class="p">{</span><span class="nx">Indent</span><span class="p">:</span> <span class="s">" "</span><span class="p">,</span> <span class="nx">Newline</span><span class="p">:</span> <span class="s">"\n"</span><span class="p">,</span> <span class="nx">Space</span><span class="p">:</span> <span class="s">" "</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// { </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "colors": [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "black", </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "silver" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getmtnbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..mountain_bikes[*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getmodels</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..model"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Salacia","Mimas","Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_get2mtnbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..mountain_bikes[0:2].model"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGetWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONGetArgs</span><span class="p">{</span><span class="nx">Indent</span><span class="p">:</span> <span class="s">" "</span><span class="p">,</span> <span class="nx">Newline</span><span class="p">:</span> <span class="s">"\n"</span><span class="p">,</span> <span class="nx">Space</span><span class="p">:</span> <span class="s">" "</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// { </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "colors": [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "black", </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "white" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ], </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "description": "Redesigned for the 2020 model year </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"$..[?(@.specs.material == 'alloy')].model"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Mimas","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter3</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Salacia","Mimas","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter4</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatebikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1475,3941,1920,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1375,3841,1820,1972,3164] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1475,3941,1920,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatefilters1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mi">1500</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1500,3941,1500,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatefilters2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"pink\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [3 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..[*].colors"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["black","silver","pink"],["black","silver","pink"],["black","white"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_json_tutorial-stepfilter2')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_json_tutorial-stepfilter2" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/json_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_json_tutorial-stepfilter2" name="json_tutorial-stepfilter2" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_json_tutorial-stepfilter2" title="Open example"> C# </label> <div aria-labelledby="tab-json_tutorial-stepfilter2" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_json_tutorial-stepfilter2" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.RedisStackCommands</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">Json_tutorial</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\"Hyperion\""</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">JsonType</span><span class="p">[]</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Type</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res3</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; STRING</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_get' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">StrLen</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res4</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 8</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">StrAppend</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">" (Enduro bikes)"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res5</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 23</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'str' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">0</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1.5</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2.5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="p">-</span><span class="m">0.75</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1.75</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'num' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="k">new</span> <span class="kt">object?</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="k">new</span> <span class="p">{</span> <span class="n">crashes</span> <span class="p">=</span> <span class="m">0</span> <span class="p">},</span> <span class="k">null</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$[1].crashes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res13</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [0]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Del</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$.[-1]"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res14</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res15</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="k">new</span> <span class="kt">object</span><span class="p">[]</span> <span class="p">{</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res16</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrAppend</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res17</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res18</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrInsert</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res19</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res20</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem","Prickett","Royce","Castilla"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrTrim</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res21</span><span class="p">));</span> <span class="c1">// 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res22</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span><span class="p">[]</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrPop</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="p">(</span><span class="kt">object</span><span class="p">[])</span><span class="n">res23</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "Prickett"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span><span class="p">[]</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrPop</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="p">(</span><span class="kt">object</span><span class="p">[])</span><span class="n">res24</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; &lt;Empty string&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="p">{</span> <span class="n">model</span> <span class="p">=</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Ergonom"</span><span class="p">,</span> <span class="n">price</span> <span class="p">=</span> <span class="m">4972</span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res25</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ObjLen</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res26</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">IEnumerable</span><span class="p">&lt;</span><span class="n">HashSet</span><span class="p">&lt;</span><span class="kt">string</span><span class="p">&gt;&gt;</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ObjKeys</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res27</span><span class="p">.</span><span class="n">Select</span><span class="p">(</span><span class="n">b</span> <span class="p">=&gt;</span> <span class="s">$"{string.Join("</span><span class="p">,</span> <span class="s">", b.Select(c =&gt; $"</span><span class="p">{</span><span class="n">c</span><span class="p">}</span><span class="s">"))}"</span><span class="p">))</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> <span class="c1">// &gt;&gt;&gt; model, brand, price</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'obj' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">string</span> <span class="n">inventoryJson</span> <span class="p">=</span> <span class="s">@" </span></span></span><span class="line"><span class="cl"><span class="s">{ </span></span></span><span class="line"><span class="cl"><span class="s"> ""inventory"": { </span></span></span><span class="line"><span class="cl"><span class="s"> ""mountain_bikes"": [ </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:1"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Phoebe"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there\u2019s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 1920, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""carbon"", ""weight"": 13.1}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""silver""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:2"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Quaoar"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and tear. All in all it's an impressive package for the price, making it very competitive."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 2072, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""aluminium"", ""weight"": 7.9}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""white""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:3"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Weywot"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 3264, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""alloy"", ""weight"": 13.8} </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s"> ], </span></span></span><span class="line"><span class="cl"><span class="s"> ""commuter_bikes"": [ </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:4"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Salacia"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, this is a bike which doesn\u2019t break the bank and delivers craved performance. It\u2019s for the rider who wants both efficiency and capability."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 1475, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""aluminium"", ""weight"": 16.6}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""silver""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:5"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Mimas"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 3941, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""alloy"", ""weight"": 11.6} </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s"> ] </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s">}"</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">inventoryJson</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res28</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.*"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; {[[{"id":"bike:1","model":"Phoebe", ...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res30</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res32</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res32</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_mtnbikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res33</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res33</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot","Salacia","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_models' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res34</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[0:2].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res34</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get2mtnbikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res35</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res35</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [{"id":"bike:2","model":"Quaoar","description":"Redesigned for the 2020 model year...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter1' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res36</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[?(@.specs.material == 'alloy')].model"</span> </span></span><span class="line hl"><span class="cl"> <span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res36</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Weywot","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res37</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res37</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot","Salacia","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter3' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res38</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res38</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res39</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res39</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res40</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res40</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res41</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res41</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter4' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res42</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..price"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res42</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res43</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="p">-</span><span class="m">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res43</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1820, 1972, 3164, 1375, 3841</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res44</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res44</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1920, 2072, 3264, 1475, 3941</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res45</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">1500</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res45</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res46</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..price"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res46</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [1500,2072,3264,1500,3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters1' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res47</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrAppend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s">"pink"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res47</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 3, 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res48</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[*].colors"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res48</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["black","silver","pink"],["black","white"],["black","silver","pink"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_json_tutorial-stepfilter2')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_json_tutorial-stepfilter2" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/Json_tutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> This example, valid from version v2.4.2 onwards, filters only bikes whose material begins with "al-" using regex match. Note that this match is case-insensitive because of the prefix <code> (?i) </code> in the regular expression pattern <code> "(?i)al" </code> : </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="json_tutorial-stepfilter3"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_json_tutorial-stepfilter3" name="json_tutorial-stepfilter3" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_json_tutorial-stepfilter3" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-json_tutorial-stepfilter3" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_json_tutorial-stepfilter3" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">JSON.GET bikes:inventory '$..[?(@.specs.material =~ "(?i)al")].model' </span></span><span class="line hl"><span class="cl">"[\"Quaoar\",\"Weywot\",\"Salacia\",\"Mimas\"]"</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_json_tutorial-stepfilter3')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_json_tutorial-stepfilter3" name="json_tutorial-stepfilter3" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_json_tutorial-stepfilter3" title="Open example"> Python </label> <div aria-labelledby="tab-json_tutorial-stepfilter3" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_json_tutorial-stepfilter3" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for JSON doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/json/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s1">'"Hyperion"'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Hyperion"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['string']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">strlen</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [10]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">strappend</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s1">'" (Enduro bikes)"'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 27</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Hyperion"" (Enduro bikes)"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [2.5]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1.75]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"Deimos"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"crashes"</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span> <span class="kc">None</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['["Deimos", { "crashes": 0 }, null]']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$[1].crashes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['0']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$.[-1]"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Deimos', {'crashes': 0}]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrappend</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s2">"Norem"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Norem']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrinsert</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">,</span> <span class="s2">"Royce"</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [4]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Norem', 'Prickett', 'Royce', 'Castilla']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrtrim</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res21</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res22</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res22</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Prickett']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res23</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrpop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res23</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Prickett"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res24</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrpop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res24</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [None]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res25</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Deimos"</span><span class="p">,</span> <span class="s2">"brand"</span><span class="p">:</span> <span class="s2">"Ergonom"</span><span class="p">,</span> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">4972</span><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res25</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res26</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">objlen</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res26</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [3]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">objkeys</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['model', 'brand', 'price']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">inventory_json</span> <span class="o">=</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"inventory"</span><span class="p">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mountain_bikes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This is a mid-travel trail slayer that is a fantastic "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"gives plenty of gear range to tackle hills and there</span><span class="se">\u2019</span><span class="s2">s room for "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mudguards and a rack too. This is the bike for the rider who wants "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"carbon"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"Redesigned for the 2020 model year, this bike "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"impressed our testers and is the best all-around trail bike we've "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"ever tested. The Shimano gear system effectively does away with an "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"external cassette, so is super low maintenance in terms of wear "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"and tear. All in all it's an impressive package for the price, "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"white"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This bike gives kids aged six years and older "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"a durable and uberlight mountain bike for their first experience "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"on tracks and easy cruising through forests and fields. A set of "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"ability. If you're after a budget option, this is one of the best "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"alloy"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="s2">"commuter_bikes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This bike is a great option for anyone who just "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"wants a bike to get about on With a slick-shifting Claris gears "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"from Shimano</span><span class="se">\u2019</span><span class="s2">s, this is a bike which doesn</span><span class="se">\u2019</span><span class="s2">t break the "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bank and delivers craved performance. It</span><span class="se">\u2019</span><span class="s2">s for the rider "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"A real joy to ride, this bike got very high "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"scores in last years Bike of the year report. The carefully "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"Vittoria Zaffiro tires give balance and grip.It includes "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"conveniently placed thumb throttle. Put it all together and you "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"alloy"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="n">inventory_json</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; [[{'id': 'bike:1', 'model': 'Phoebe',</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 'description': 'This is a mid-travel trail slayer...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[*].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s1">'$.inventory["mountain_bikes"][*].model'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..mountain_bikes[*].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot', 'Salacia', 'Mimas']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..mountain_bikes[0:2].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; [{'id': 'bike:2', 'model': 'Quaoar',</span> </span></span><span class="line"><span class="cl"><span class="c1"># 'description': "Redesigned for the 2020 model year...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[?(@.specs.material == 'alloy')].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Weywot', 'Mimas']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Quaoar', 'Weywot', 'Salacia', 'Mimas']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Quaoar', 'Weywot']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1920, 2072, 3264, 1475, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1820, 1972, 3164, 1375, 3841]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1920, 2072, 3264, 1475, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> <span class="mi">1500</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1500, 2072, 3264, 1500, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrappend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s2">"pink"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [3, 3]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[*].colors"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="n">res21</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['black', 'silver', 'pink'], ['black', 'white'], ['black', 'silver', 'pink']]</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_json_tutorial-stepfilter3')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_json_tutorial-stepfilter3" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_json.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_json_tutorial-stepfilter3" name="json_tutorial-stepfilter3" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_json_tutorial-stepfilter3" title="Open example"> Node.js </label> <div aria-labelledby="tab-json_tutorial-stepfilter3" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_json_tutorial-stepfilter3" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">createClient</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s1">'"Hyperion"'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// "Hyperion" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// [ 'string' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">strLen</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// [10] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">strAppend</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s1">'" (Enduro bikes)"'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// 27 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// ['"Hyperion"" (Enduro bikes)"'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"Deimos"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"crashes"</span><span class="o">:</span> <span class="mi">0</span> <span class="p">},</span> <span class="kc">null</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 }, null ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$[1].crashes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 }, null ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$.[-1]"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 } ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrAppend</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s2">"Norem"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">);</span> <span class="c1">// [ 'Norem' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrInsert</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">,</span> <span class="s2">"Royse"</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">);</span> <span class="c1">// [4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">);</span> <span class="c1">// [ 'Norem', 'Prickett', 'Royse', 'Castilla' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrTrim</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">);</span> <span class="c1">// [ 'Prickett' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res23</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrPop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res23</span><span class="p">);</span> <span class="c1">// [ 'Prickett' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res24</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrPop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res24</span><span class="p">);</span> <span class="c1">// [null] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res25</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"brand"</span><span class="o">:</span> <span class="s2">"Ergonom"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">4972</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res25</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res26</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">objLen</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res26</span><span class="p">);</span> <span class="c1">// [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">objKeys</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27</span><span class="p">);</span> <span class="c1">// [['model', 'brand', 'price']] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">inventoryJSON</span> <span class="o">=</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"inventory"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mountain_bikes"</span><span class="o">:</span> <span class="p">[{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there\u2019s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"carbon"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">13.1</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">7.9</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"white"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"alloy"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">13.8</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="s2">"commuter_bikes"</span><span class="o">:</span> <span class="p">[{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, this is a bike which doesn\u2019t break the bank and delivers craved performance. It\u2019s for the rider who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">16.6</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"alloy"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">11.6</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">};</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="nx">inventoryJSON</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$.inventory.*"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="cm">/* </span></span></span><span class="line"><span class="cl"><span class="cm">[ </span></span></span><span class="line"><span class="cl"><span class="cm"> [ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:1', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Phoebe', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there’s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 1920, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:2', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Quaoar', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 2072, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:3', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Weywot', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 3264, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm"> ], </span></span></span><span class="line"><span class="cl"><span class="cm"> [ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:4', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Salacia', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano’s, this is a bike which doesn’t break the bank and delivers craved performance. It’s for the rider who wants both efficiency and capability.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 1475, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:5', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Mimas', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 3941, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm"> ] </span></span></span><span class="line"><span class="cl"><span class="cm">] </span></span></span><span class="line"><span class="cl"><span class="cm">*/</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res30</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$.inventory.mountain_bikes[*].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res30</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res31</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s1">'$.inventory["mountain_bikes"][*].model'</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res31</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res32</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[*].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res32</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res33</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res33</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot', 'Salacia', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res34</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[0:2].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res34</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res35</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res35</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="cm">/* </span></span></span><span class="line"><span class="cl"><span class="cm">[ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:2', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Quaoar', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 2072, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: { material: 'aluminium', weight: 7.9 }, </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [ 'black', 'white' ] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm">] </span></span></span><span class="line"><span class="cl"><span class="cm">*/</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1">// names of bikes made from an alloy </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res36</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[?(@.specs.material == 'alloy')].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// ['Weywot', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res37</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[?(@.specs.material =~ '(?i)al')].model"</span> </span></span><span class="line hl"><span class="cl"><span class="p">});</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37</span><span class="p">);</span> <span class="c1">// ['Quaoar', 'Weywot', 'Salacia', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37a</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[0].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37b</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[1].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37c</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[2].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37d</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37d</span><span class="p">);</span> <span class="c1">// ['Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res38</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..price"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res38</span><span class="p">);</span> <span class="c1">// [1920, 2072, 3264, 1475, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res39</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res39</span><span class="p">);</span> <span class="c1">// [1820, 1972, 3164, 1375, 3841] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40</span><span class="p">);</span> <span class="c1">// [1920, 2072, 3264, 1475, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40a</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.*[?(@.price&lt;2000)].price'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mi">1500</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1">// Get all prices from the inventory </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res40b</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$..price'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40b</span><span class="p">);</span> <span class="c1">// [1500, 2072, 3264, 1500, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res41</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrAppend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s2">"pink"</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res41</span><span class="p">);</span> <span class="c1">// [3, 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res42</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[*].colors"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res42</span><span class="p">);</span> <span class="c1">// [['black', 'silver', 'pink'], ['black', 'white'], ['black', 'silver', 'pink']] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_json_tutorial-stepfilter3')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_json_tutorial-stepfilter3" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-json.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_json_tutorial-stepfilter3" name="json_tutorial-stepfilter3" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_json_tutorial-stepfilter3" title="Open example"> Java </label> <div aria-labelledby="tab-json_tutorial-stepfilter3" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_json_tutorial-stepfilter3" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.json.Path2</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.json.JSONArray</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.json.JSONObject</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">JsonExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">"\"Hyperion\""</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Class</span><span class="o">&lt;?&gt;&gt;</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonType</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [class java.lang.String] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_get' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonStrLen</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [8] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonStrAppend</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">" (Enduro bikes)"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [23] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'str' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">0</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mf">1.5</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="o">-</span><span class="mf">0.75</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'num' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">JSONArray</span><span class="o">()</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"Deimos"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="k">new</span> <span class="n">JSONObject</span><span class="o">().</span><span class="na">put</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="mi">0</span><span class="o">))</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">((</span><span class="n">Object</span><span class="o">)</span> <span class="kc">null</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$[1].crashes"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [0] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonDel</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.[-1]"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="k">new</span> <span class="n">JSONArray</span><span class="o">());</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrAppendWithEscape</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">"Norem"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrInsertWithEscape</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">,</span> <span class="s">"Prickett"</span><span class="o">,</span> <span class="s">"Royce"</span><span class="o">,</span> <span class="s">"Castilla"</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res19</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["Norem","Prickett","Royce","Castilla"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrTrim</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">,</span> <span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res23</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrPop</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res23</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [Prickett] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res24</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrPop</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res24</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [null] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res25</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">JSONObject</span><span class="o">()</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"model"</span><span class="o">,</span> <span class="s">"Deimos"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"brand"</span><span class="o">,</span> <span class="s">"Ergonom"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"price"</span><span class="o">,</span> <span class="mi">4972</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res25</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res26</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonObjLen</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res26</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;&gt;</span> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonObjKeys</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [[price, model, brand]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'obj' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">inventory_json</span> <span class="o">=</span> <span class="s">"{"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"inventory\": {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"mountain_bikes\": ["</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:1\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Phoebe\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This is a mid-travel trail slayer that is a "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for mudguards "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and a rack too. This is the bike for the rider who wants trail manners with "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"low fuss ownership.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1920,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"carbon\", \"weight\": 13.1},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"silver\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:2\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Quaoar\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"Redesigned for the 2020 model year, this "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"bike impressed our testers and is the best all-around trail bike we've ever "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"tested. The Shimano gear system effectively does away with an external cassette, "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"so is super low maintenance in terms of wear and tear. All in all it's an "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"impressive package for the price, making it very competitive.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 2072,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"aluminium\", \"weight\": 7.9},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"white\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:3\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Weywot\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This bike gives kids aged six years and older "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"a durable and uberlight mountain bike for their first experience on tracks and easy "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"provide ample stopping ability. If you're after a budget option, this is one of the "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"best bikes you could get.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3264,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"alloy\", \"weight\": 13.8}"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" ],"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"commuter_bikes\": ["</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:4\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Salacia\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This bike is a great option for anyone who just "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"this is a bike which doesn\u2019t break the bank and delivers craved performance. "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"It\u2019s for the rider who wants both efficiency and capability.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1475,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"aluminium\", \"weight\": 16.6},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"silver\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:5\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Mimas\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"A real joy to ride, this bike got very high scores "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"in last years Bike of the year report. The carefully crafted 50-34 tooth chainset "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"throttle. Put it all together and you get a bike that helps redefine what can be "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"done for this price.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3941,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"alloy\", \"weight\": 11.6}"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" ]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"}"</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="n">inventory_json</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res28</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [[{"specs":{"material":"carbon","weight":13.1},"price":1920, ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res30</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res30</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res31</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res31</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res32</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res32</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_mtnbikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res33</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..model"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res33</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot","Salacia","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_models' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res34</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[0:2].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res34</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get2mtnbikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res35</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res35</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [{"specs":{"material":"aluminium","weight":7.9},"price":2072,... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter1' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res36</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[?(@.specs.material == 'alloy')].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Weywot","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">Object</span> <span class="n">res37</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="o">)</span> </span></span><span class="line hl"><span class="cl"> <span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res37</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot","Salacia","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter3' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res38</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res38</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter4' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res39</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res39</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res40</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">),</span> <span class="o">-</span><span class="mi">100</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res40</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1820,1972,3164,1375,3841] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res41</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">),</span> <span class="mi">100</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res41</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="o">),</span> <span class="mi">1500</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res42</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res42</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1500,2072,3264,1500,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters1' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res43</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrAppendWithEscape</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"pink\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res43</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [3, 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res44</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[*].colors"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res44</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["black","silver","\"pink\""],["black","white"],["black","silver","\"pink\""]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">close</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_json_tutorial-stepfilter3')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_json_tutorial-stepfilter3" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/JsonExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_json_tutorial-stepfilter3" name="json_tutorial-stepfilter3" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_json_tutorial-stepfilter3" title="Open example"> Go </label> <div aria-labelledby="tab-json_tutorial-stepfilter3" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_json_tutorial-stepfilter3" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_setget</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Hyperion\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONType</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [[string]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_str</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Hyperion\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONStrLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res4</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 8 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONStrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\" (Enduro bikes)\""</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res5</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 23 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_num</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_arr</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"crashes"</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kc">nil</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$[1].crashes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [0] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONDel</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$.[-1]"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_arr2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{}).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\"Norem\""</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrInsert</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Prickett\""</span><span class="p">,</span> <span class="s">"\"Royce\""</span><span class="p">,</span> <span class="s">"\"Castilla\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Norem", "Prickett", "Royce", "Castilla"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">rangeStop</span> <span class="o">:=</span> <span class="mi">1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrTrimWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONArrTrimArgs</span><span class="p">{</span><span class="nx">Start</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">Stop</span><span class="p">:</span> <span class="o">&amp;</span><span class="nx">rangeStop</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res23</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res23</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res24</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res24</span><span class="p">)</span> <span class="c1">// [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_obj</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res25</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"brand"</span><span class="p">:</span> <span class="s">"Ergonom"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">4972</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res25</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res26</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONObjLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res26</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res27</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONObjKeys</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res27</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [brand model price] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">var</span> <span class="nx">inventory_json</span> <span class="p">=</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"inventory"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"mountain_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This is a mid-travel trail slayer that is a fantastic "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"mudguards and a rack too. This is the bike for the rider who wants "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"carbon"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"Redesigned for the 2020 model year, this bike "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"impressed our testers and is the best all-around trail bike we've "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ever tested. The Shimano gear system effectively does away with an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"external cassette, so is super low maintenance in terms of wear "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"and tear. All in all it's an impressive package for the price, "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"white"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike gives kids aged six years and older "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a durable and uberlight mountain bike for their first experience "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"on tracks and easy cruising through forests and fields. A set of "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ability. If you're after a budget option, this is one of the best "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"commuter_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike is a great option for anyone who just "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"from Shimano\u2019s, this is a bike which doesn\u2019t break the "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bank and delivers craved performance. It\u2019s for the rider "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"A real joy to ride, this bike got very high "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"scores in last years Bike of the year report. The carefully "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"Vittoria Zaffiro tires give balance and grip.It includes "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"conveniently placed thumb throttle. Put it all together and you "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_setbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kd">var</span> <span class="nx">inventory_json</span> <span class="p">=</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"inventory"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"mountain_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This is a mid-travel trail slayer that is a fantastic "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"mudguards and a rack too. This is the bike for the rider who wants "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"carbon"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"Redesigned for the 2020 model year, this bike "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"impressed our testers and is the best all-around trail bike we've "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ever tested. The Shimano gear system effectively does away with an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"external cassette, so is super low maintenance in terms of wear "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"and tear. All in all it's an impressive package for the price, "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"white"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike gives kids aged six years and older "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a durable and uberlight mountain bike for their first experience "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"on tracks and easy cruising through forests and fields. A set of "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ability. If you're after a budget option, this is one of the best "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"commuter_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike is a great option for anyone who just "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"from Shimano\u2019s, this is a bike which doesn\u2019t break the "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bank and delivers craved performance. It\u2019s for the rider "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"A real joy to ride, this bike got very high "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"scores in last years Bike of the year report. The carefully "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"Vittoria Zaffiro tires give balance and grip.It includes "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"conveniently placed thumb throttle. Put it all together and you "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGetWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONGetArgs</span><span class="p">{</span><span class="nx">Indent</span><span class="p">:</span> <span class="s">" "</span><span class="p">,</span> <span class="nx">Newline</span><span class="p">:</span> <span class="s">"\n"</span><span class="p">,</span> <span class="nx">Space</span><span class="p">:</span> <span class="s">" "</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// { </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "colors": [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "black", </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "silver" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getmtnbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..mountain_bikes[*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getmodels</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..model"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Salacia","Mimas","Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_get2mtnbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..mountain_bikes[0:2].model"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGetWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONGetArgs</span><span class="p">{</span><span class="nx">Indent</span><span class="p">:</span> <span class="s">" "</span><span class="p">,</span> <span class="nx">Newline</span><span class="p">:</span> <span class="s">"\n"</span><span class="p">,</span> <span class="nx">Space</span><span class="p">:</span> <span class="s">" "</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// { </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "colors": [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "black", </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "white" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ], </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "description": "Redesigned for the 2020 model year </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..[?(@.specs.material == 'alloy')].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Mimas","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter3</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Salacia","Mimas","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter4</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatebikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1475,3941,1920,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1375,3841,1820,1972,3164] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1475,3941,1920,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatefilters1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mi">1500</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1500,3941,1500,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatefilters2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"pink\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [3 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..[*].colors"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["black","silver","pink"],["black","silver","pink"],["black","white"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_json_tutorial-stepfilter3')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_json_tutorial-stepfilter3" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/json_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_json_tutorial-stepfilter3" name="json_tutorial-stepfilter3" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_json_tutorial-stepfilter3" title="Open example"> C# </label> <div aria-labelledby="tab-json_tutorial-stepfilter3" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_json_tutorial-stepfilter3" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.RedisStackCommands</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">Json_tutorial</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\"Hyperion\""</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">JsonType</span><span class="p">[]</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Type</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res3</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; STRING</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_get' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">StrLen</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res4</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 8</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">StrAppend</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">" (Enduro bikes)"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res5</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 23</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'str' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">0</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1.5</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2.5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="p">-</span><span class="m">0.75</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1.75</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'num' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="k">new</span> <span class="kt">object?</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="k">new</span> <span class="p">{</span> <span class="n">crashes</span> <span class="p">=</span> <span class="m">0</span> <span class="p">},</span> <span class="k">null</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$[1].crashes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res13</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [0]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Del</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$.[-1]"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res14</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res15</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="k">new</span> <span class="kt">object</span><span class="p">[]</span> <span class="p">{</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res16</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrAppend</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res17</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res18</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrInsert</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res19</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res20</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem","Prickett","Royce","Castilla"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrTrim</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res21</span><span class="p">));</span> <span class="c1">// 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res22</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span><span class="p">[]</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrPop</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="p">(</span><span class="kt">object</span><span class="p">[])</span><span class="n">res23</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "Prickett"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span><span class="p">[]</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrPop</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="p">(</span><span class="kt">object</span><span class="p">[])</span><span class="n">res24</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; &lt;Empty string&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="p">{</span> <span class="n">model</span> <span class="p">=</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Ergonom"</span><span class="p">,</span> <span class="n">price</span> <span class="p">=</span> <span class="m">4972</span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res25</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ObjLen</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res26</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">IEnumerable</span><span class="p">&lt;</span><span class="n">HashSet</span><span class="p">&lt;</span><span class="kt">string</span><span class="p">&gt;&gt;</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ObjKeys</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res27</span><span class="p">.</span><span class="n">Select</span><span class="p">(</span><span class="n">b</span> <span class="p">=&gt;</span> <span class="s">$"{string.Join("</span><span class="p">,</span> <span class="s">", b.Select(c =&gt; $"</span><span class="p">{</span><span class="n">c</span><span class="p">}</span><span class="s">"))}"</span><span class="p">))</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> <span class="c1">// &gt;&gt;&gt; model, brand, price</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'obj' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">string</span> <span class="n">inventoryJson</span> <span class="p">=</span> <span class="s">@" </span></span></span><span class="line"><span class="cl"><span class="s">{ </span></span></span><span class="line"><span class="cl"><span class="s"> ""inventory"": { </span></span></span><span class="line"><span class="cl"><span class="s"> ""mountain_bikes"": [ </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:1"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Phoebe"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there\u2019s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 1920, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""carbon"", ""weight"": 13.1}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""silver""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:2"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Quaoar"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and tear. All in all it's an impressive package for the price, making it very competitive."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 2072, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""aluminium"", ""weight"": 7.9}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""white""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:3"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Weywot"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 3264, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""alloy"", ""weight"": 13.8} </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s"> ], </span></span></span><span class="line"><span class="cl"><span class="s"> ""commuter_bikes"": [ </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:4"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Salacia"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, this is a bike which doesn\u2019t break the bank and delivers craved performance. It\u2019s for the rider who wants both efficiency and capability."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 1475, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""aluminium"", ""weight"": 16.6}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""silver""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:5"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Mimas"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 3941, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""alloy"", ""weight"": 11.6} </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s"> ] </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s">}"</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">inventoryJson</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res28</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.*"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; {[[{"id":"bike:1","model":"Phoebe", ...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res30</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res32</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res32</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_mtnbikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res33</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res33</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot","Salacia","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_models' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res34</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[0:2].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res34</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get2mtnbikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res35</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res35</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [{"id":"bike:2","model":"Quaoar","description":"Redesigned for the 2020 model year...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter1' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res36</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[?(@.specs.material == 'alloy')].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res36</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Weywot","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res37</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span> </span></span><span class="line hl"><span class="cl"> <span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res37</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot","Salacia","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter3' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res38</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res38</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res39</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res39</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res40</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res40</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res41</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res41</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter4' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res42</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..price"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res42</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res43</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="p">-</span><span class="m">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res43</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1820, 1972, 3164, 1375, 3841</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res44</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res44</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1920, 2072, 3264, 1475, 3941</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res45</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">1500</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res45</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res46</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..price"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res46</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [1500,2072,3264,1500,3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters1' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res47</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrAppend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s">"pink"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res47</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 3, 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res48</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[*].colors"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res48</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["black","silver","pink"],["black","white"],["black","silver","pink"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_json_tutorial-stepfilter3')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_json_tutorial-stepfilter3" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/Json_tutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> You can also specify a regex pattern using a property from the JSON object itself. For example, we can add a string property named <code> regex_pat </code> to each mountain bike, with the value <code> "(?i)al" </code> to match the material, as in the previous example. We can then match <code> regex_pat </code> against the bike's material: </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="json_tutorial-stepfilter4"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_json_tutorial-stepfilter4" name="json_tutorial-stepfilter4" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_json_tutorial-stepfilter4" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-json_tutorial-stepfilter4" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_json_tutorial-stepfilter4" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; JSON.SET bikes:inventory $.inventory.mountain_bikes[0].regex_pat '"(?i)al"' </span></span><span class="line hl"><span class="cl">OK </span></span><span class="line hl"><span class="cl">&gt; JSON.SET bikes:inventory $.inventory.mountain_bikes[1].regex_pat '"(?i)al"' </span></span><span class="line hl"><span class="cl">OK </span></span><span class="line hl"><span class="cl">&gt; JSON.SET bikes:inventory $.inventory.mountain_bikes[2].regex_pat '"(?i)al"' </span></span><span class="line hl"><span class="cl">OK </span></span><span class="line hl"><span class="cl">&gt; JSON.GET bikes:inventory '$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model' </span></span><span class="line hl"><span class="cl">"[\"Quaoar\",\"Weywot\"]"</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_json_tutorial-stepfilter4')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_json_tutorial-stepfilter4" name="json_tutorial-stepfilter4" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_json_tutorial-stepfilter4" title="Open example"> Python </label> <div aria-labelledby="tab-json_tutorial-stepfilter4" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_json_tutorial-stepfilter4" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for JSON doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/json/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s1">'"Hyperion"'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Hyperion"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['string']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">strlen</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [10]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">strappend</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s1">'" (Enduro bikes)"'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 27</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Hyperion"" (Enduro bikes)"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [2.5]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1.75]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"Deimos"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"crashes"</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span> <span class="kc">None</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['["Deimos", { "crashes": 0 }, null]']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$[1].crashes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['0']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$.[-1]"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Deimos', {'crashes': 0}]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrappend</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s2">"Norem"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Norem']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrinsert</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">,</span> <span class="s2">"Royce"</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [4]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Norem', 'Prickett', 'Royce', 'Castilla']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrtrim</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res21</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res22</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res22</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Prickett']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res23</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrpop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res23</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Prickett"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res24</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrpop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res24</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [None]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res25</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Deimos"</span><span class="p">,</span> <span class="s2">"brand"</span><span class="p">:</span> <span class="s2">"Ergonom"</span><span class="p">,</span> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">4972</span><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res25</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res26</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">objlen</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res26</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [3]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">objkeys</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['model', 'brand', 'price']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">inventory_json</span> <span class="o">=</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"inventory"</span><span class="p">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mountain_bikes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This is a mid-travel trail slayer that is a fantastic "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"gives plenty of gear range to tackle hills and there</span><span class="se">\u2019</span><span class="s2">s room for "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mudguards and a rack too. This is the bike for the rider who wants "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"carbon"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"Redesigned for the 2020 model year, this bike "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"impressed our testers and is the best all-around trail bike we've "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"ever tested. The Shimano gear system effectively does away with an "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"external cassette, so is super low maintenance in terms of wear "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"and tear. All in all it's an impressive package for the price, "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"white"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This bike gives kids aged six years and older "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"a durable and uberlight mountain bike for their first experience "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"on tracks and easy cruising through forests and fields. A set of "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"ability. If you're after a budget option, this is one of the best "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"alloy"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="s2">"commuter_bikes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This bike is a great option for anyone who just "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"wants a bike to get about on With a slick-shifting Claris gears "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"from Shimano</span><span class="se">\u2019</span><span class="s2">s, this is a bike which doesn</span><span class="se">\u2019</span><span class="s2">t break the "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bank and delivers craved performance. It</span><span class="se">\u2019</span><span class="s2">s for the rider "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"A real joy to ride, this bike got very high "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"scores in last years Bike of the year report. The carefully "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"Vittoria Zaffiro tires give balance and grip.It includes "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"conveniently placed thumb throttle. Put it all together and you "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"alloy"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="n">inventory_json</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; [[{'id': 'bike:1', 'model': 'Phoebe',</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 'description': 'This is a mid-travel trail slayer...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[*].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s1">'$.inventory["mountain_bikes"][*].model'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..mountain_bikes[*].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot', 'Salacia', 'Mimas']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..mountain_bikes[0:2].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; [{'id': 'bike:2', 'model': 'Quaoar',</span> </span></span><span class="line"><span class="cl"><span class="c1"># 'description': "Redesigned for the 2020 model year...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[?(@.specs.material == 'alloy')].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Weywot', 'Mimas']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Quaoar', 'Weywot', 'Salacia', 'Mimas']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line hl"><span class="cl"><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line hl"><span class="cl"><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line hl"><span class="cl"><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Quaoar', 'Weywot']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1920, 2072, 3264, 1475, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1820, 1972, 3164, 1375, 3841]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1920, 2072, 3264, 1475, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> <span class="mi">1500</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1500, 2072, 3264, 1500, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrappend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s2">"pink"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [3, 3]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[*].colors"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="n">res21</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['black', 'silver', 'pink'], ['black', 'white'], ['black', 'silver', 'pink']]</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_json_tutorial-stepfilter4')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_json_tutorial-stepfilter4" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_json.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_json_tutorial-stepfilter4" name="json_tutorial-stepfilter4" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_json_tutorial-stepfilter4" title="Open example"> Node.js </label> <div aria-labelledby="tab-json_tutorial-stepfilter4" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_json_tutorial-stepfilter4" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">createClient</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s1">'"Hyperion"'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// "Hyperion" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// [ 'string' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">strLen</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// [10] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">strAppend</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s1">'" (Enduro bikes)"'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// 27 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// ['"Hyperion"" (Enduro bikes)"'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"Deimos"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"crashes"</span><span class="o">:</span> <span class="mi">0</span> <span class="p">},</span> <span class="kc">null</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 }, null ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$[1].crashes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 }, null ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$.[-1]"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 } ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrAppend</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s2">"Norem"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">);</span> <span class="c1">// [ 'Norem' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrInsert</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">,</span> <span class="s2">"Royse"</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">);</span> <span class="c1">// [4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">);</span> <span class="c1">// [ 'Norem', 'Prickett', 'Royse', 'Castilla' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrTrim</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">);</span> <span class="c1">// [ 'Prickett' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res23</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrPop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res23</span><span class="p">);</span> <span class="c1">// [ 'Prickett' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res24</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrPop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res24</span><span class="p">);</span> <span class="c1">// [null] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res25</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"brand"</span><span class="o">:</span> <span class="s2">"Ergonom"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">4972</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res25</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res26</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">objLen</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res26</span><span class="p">);</span> <span class="c1">// [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">objKeys</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27</span><span class="p">);</span> <span class="c1">// [['model', 'brand', 'price']] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">inventoryJSON</span> <span class="o">=</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"inventory"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mountain_bikes"</span><span class="o">:</span> <span class="p">[{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there\u2019s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"carbon"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">13.1</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">7.9</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"white"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"alloy"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">13.8</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="s2">"commuter_bikes"</span><span class="o">:</span> <span class="p">[{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, this is a bike which doesn\u2019t break the bank and delivers craved performance. It\u2019s for the rider who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">16.6</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"alloy"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">11.6</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">};</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="nx">inventoryJSON</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$.inventory.*"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="cm">/* </span></span></span><span class="line"><span class="cl"><span class="cm">[ </span></span></span><span class="line"><span class="cl"><span class="cm"> [ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:1', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Phoebe', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there’s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 1920, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:2', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Quaoar', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 2072, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:3', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Weywot', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 3264, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm"> ], </span></span></span><span class="line"><span class="cl"><span class="cm"> [ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:4', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Salacia', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano’s, this is a bike which doesn’t break the bank and delivers craved performance. It’s for the rider who wants both efficiency and capability.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 1475, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:5', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Mimas', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 3941, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm"> ] </span></span></span><span class="line"><span class="cl"><span class="cm">] </span></span></span><span class="line"><span class="cl"><span class="cm">*/</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res30</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$.inventory.mountain_bikes[*].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res30</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res31</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s1">'$.inventory["mountain_bikes"][*].model'</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res31</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res32</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[*].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res32</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res33</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res33</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot', 'Salacia', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res34</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[0:2].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res34</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res35</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res35</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="cm">/* </span></span></span><span class="line"><span class="cl"><span class="cm">[ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:2', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Quaoar', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 2072, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: { material: 'aluminium', weight: 7.9 }, </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [ 'black', 'white' ] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm">] </span></span></span><span class="line"><span class="cl"><span class="cm">*/</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1">// names of bikes made from an alloy </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res36</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[?(@.specs.material == 'alloy')].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// ['Weywot', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[?(@.specs.material =~ '(?i)al')].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37</span><span class="p">);</span> <span class="c1">// ['Quaoar', 'Weywot', 'Salacia', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res37a</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[0].regex_pat'</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line hl"><span class="cl"><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res37b</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[1].regex_pat'</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line hl"><span class="cl"><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res37c</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[2].regex_pat'</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line hl"><span class="cl"><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res37d</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model'</span> </span></span><span class="line hl"><span class="cl"><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37d</span><span class="p">);</span> <span class="c1">// ['Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res38</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..price"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res38</span><span class="p">);</span> <span class="c1">// [1920, 2072, 3264, 1475, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res39</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res39</span><span class="p">);</span> <span class="c1">// [1820, 1972, 3164, 1375, 3841] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40</span><span class="p">);</span> <span class="c1">// [1920, 2072, 3264, 1475, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40a</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.*[?(@.price&lt;2000)].price'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mi">1500</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1">// Get all prices from the inventory </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res40b</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$..price'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40b</span><span class="p">);</span> <span class="c1">// [1500, 2072, 3264, 1500, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res41</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrAppend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s2">"pink"</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res41</span><span class="p">);</span> <span class="c1">// [3, 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res42</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[*].colors"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res42</span><span class="p">);</span> <span class="c1">// [['black', 'silver', 'pink'], ['black', 'white'], ['black', 'silver', 'pink']] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_json_tutorial-stepfilter4')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_json_tutorial-stepfilter4" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-json.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_json_tutorial-stepfilter4" name="json_tutorial-stepfilter4" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_json_tutorial-stepfilter4" title="Open example"> Java </label> <div aria-labelledby="tab-json_tutorial-stepfilter4" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_json_tutorial-stepfilter4" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.json.Path2</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.json.JSONArray</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.json.JSONObject</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">JsonExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">"\"Hyperion\""</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Class</span><span class="o">&lt;?&gt;&gt;</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonType</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [class java.lang.String] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_get' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonStrLen</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [8] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonStrAppend</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">" (Enduro bikes)"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [23] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'str' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">0</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mf">1.5</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="o">-</span><span class="mf">0.75</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'num' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">JSONArray</span><span class="o">()</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"Deimos"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="k">new</span> <span class="n">JSONObject</span><span class="o">().</span><span class="na">put</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="mi">0</span><span class="o">))</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">((</span><span class="n">Object</span><span class="o">)</span> <span class="kc">null</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$[1].crashes"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [0] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonDel</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.[-1]"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="k">new</span> <span class="n">JSONArray</span><span class="o">());</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrAppendWithEscape</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">"Norem"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrInsertWithEscape</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">,</span> <span class="s">"Prickett"</span><span class="o">,</span> <span class="s">"Royce"</span><span class="o">,</span> <span class="s">"Castilla"</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res19</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["Norem","Prickett","Royce","Castilla"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrTrim</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">,</span> <span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res23</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrPop</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res23</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [Prickett] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res24</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrPop</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res24</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [null] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res25</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">JSONObject</span><span class="o">()</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"model"</span><span class="o">,</span> <span class="s">"Deimos"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"brand"</span><span class="o">,</span> <span class="s">"Ergonom"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"price"</span><span class="o">,</span> <span class="mi">4972</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res25</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res26</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonObjLen</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res26</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;&gt;</span> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonObjKeys</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [[price, model, brand]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'obj' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">inventory_json</span> <span class="o">=</span> <span class="s">"{"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"inventory\": {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"mountain_bikes\": ["</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:1\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Phoebe\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This is a mid-travel trail slayer that is a "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for mudguards "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and a rack too. This is the bike for the rider who wants trail manners with "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"low fuss ownership.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1920,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"carbon\", \"weight\": 13.1},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"silver\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:2\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Quaoar\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"Redesigned for the 2020 model year, this "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"bike impressed our testers and is the best all-around trail bike we've ever "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"tested. The Shimano gear system effectively does away with an external cassette, "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"so is super low maintenance in terms of wear and tear. All in all it's an "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"impressive package for the price, making it very competitive.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 2072,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"aluminium\", \"weight\": 7.9},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"white\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:3\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Weywot\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This bike gives kids aged six years and older "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"a durable and uberlight mountain bike for their first experience on tracks and easy "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"provide ample stopping ability. If you're after a budget option, this is one of the "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"best bikes you could get.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3264,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"alloy\", \"weight\": 13.8}"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" ],"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"commuter_bikes\": ["</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:4\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Salacia\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This bike is a great option for anyone who just "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"this is a bike which doesn\u2019t break the bank and delivers craved performance. "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"It\u2019s for the rider who wants both efficiency and capability.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1475,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"aluminium\", \"weight\": 16.6},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"silver\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:5\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Mimas\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"A real joy to ride, this bike got very high scores "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"in last years Bike of the year report. The carefully crafted 50-34 tooth chainset "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"throttle. Put it all together and you get a bike that helps redefine what can be "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"done for this price.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3941,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"alloy\", \"weight\": 11.6}"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" ]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"}"</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="n">inventory_json</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res28</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [[{"specs":{"material":"carbon","weight":13.1},"price":1920, ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res30</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res30</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res31</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res31</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res32</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res32</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_mtnbikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res33</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..model"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res33</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot","Salacia","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_models' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res34</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[0:2].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res34</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get2mtnbikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res35</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res35</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [{"specs":{"material":"aluminium","weight":7.9},"price":2072,... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter1' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res36</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[?(@.specs.material == 'alloy')].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Weywot","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res37</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res37</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot","Salacia","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter3' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="o">),</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line hl"><span class="cl"> <span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="o">),</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line hl"><span class="cl"> <span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="o">),</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line hl"><span class="cl"> <span class="o">);</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">Object</span> <span class="n">res38</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> </span></span><span class="line hl"><span class="cl"> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="o">)</span> </span></span><span class="line hl"><span class="cl"> <span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res38</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter4' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res39</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res39</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res40</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">),</span> <span class="o">-</span><span class="mi">100</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res40</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1820,1972,3164,1375,3841] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res41</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">),</span> <span class="mi">100</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res41</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="o">),</span> <span class="mi">1500</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res42</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res42</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1500,2072,3264,1500,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters1' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res43</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrAppendWithEscape</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"pink\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res43</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [3, 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res44</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[*].colors"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res44</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["black","silver","\"pink\""],["black","white"],["black","silver","\"pink\""]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">close</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_json_tutorial-stepfilter4')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_json_tutorial-stepfilter4" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/JsonExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_json_tutorial-stepfilter4" name="json_tutorial-stepfilter4" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_json_tutorial-stepfilter4" title="Open example"> Go </label> <div aria-labelledby="tab-json_tutorial-stepfilter4" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_json_tutorial-stepfilter4" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_setget</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Hyperion\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONType</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [[string]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_str</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Hyperion\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONStrLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res4</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 8 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONStrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\" (Enduro bikes)\""</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res5</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 23 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_num</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_arr</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"crashes"</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kc">nil</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$[1].crashes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [0] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONDel</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$.[-1]"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_arr2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{}).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\"Norem\""</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrInsert</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Prickett\""</span><span class="p">,</span> <span class="s">"\"Royce\""</span><span class="p">,</span> <span class="s">"\"Castilla\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Norem", "Prickett", "Royce", "Castilla"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">rangeStop</span> <span class="o">:=</span> <span class="mi">1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrTrimWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONArrTrimArgs</span><span class="p">{</span><span class="nx">Start</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">Stop</span><span class="p">:</span> <span class="o">&amp;</span><span class="nx">rangeStop</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res23</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res23</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res24</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res24</span><span class="p">)</span> <span class="c1">// [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_obj</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res25</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"brand"</span><span class="p">:</span> <span class="s">"Ergonom"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">4972</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res25</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res26</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONObjLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res26</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res27</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONObjKeys</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res27</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [brand model price] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">var</span> <span class="nx">inventory_json</span> <span class="p">=</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"inventory"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"mountain_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This is a mid-travel trail slayer that is a fantastic "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"mudguards and a rack too. This is the bike for the rider who wants "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"carbon"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"Redesigned for the 2020 model year, this bike "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"impressed our testers and is the best all-around trail bike we've "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ever tested. The Shimano gear system effectively does away with an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"external cassette, so is super low maintenance in terms of wear "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"and tear. All in all it's an impressive package for the price, "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"white"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike gives kids aged six years and older "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a durable and uberlight mountain bike for their first experience "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"on tracks and easy cruising through forests and fields. A set of "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ability. If you're after a budget option, this is one of the best "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"commuter_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike is a great option for anyone who just "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"from Shimano\u2019s, this is a bike which doesn\u2019t break the "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bank and delivers craved performance. It\u2019s for the rider "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"A real joy to ride, this bike got very high "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"scores in last years Bike of the year report. The carefully "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"Vittoria Zaffiro tires give balance and grip.It includes "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"conveniently placed thumb throttle. Put it all together and you "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_setbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kd">var</span> <span class="nx">inventory_json</span> <span class="p">=</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"inventory"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"mountain_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This is a mid-travel trail slayer that is a fantastic "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"mudguards and a rack too. This is the bike for the rider who wants "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"carbon"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"Redesigned for the 2020 model year, this bike "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"impressed our testers and is the best all-around trail bike we've "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ever tested. The Shimano gear system effectively does away with an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"external cassette, so is super low maintenance in terms of wear "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"and tear. All in all it's an impressive package for the price, "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"white"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike gives kids aged six years and older "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a durable and uberlight mountain bike for their first experience "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"on tracks and easy cruising through forests and fields. A set of "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ability. If you're after a budget option, this is one of the best "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"commuter_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike is a great option for anyone who just "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"from Shimano\u2019s, this is a bike which doesn\u2019t break the "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bank and delivers craved performance. It\u2019s for the rider "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"A real joy to ride, this bike got very high "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"scores in last years Bike of the year report. The carefully "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"Vittoria Zaffiro tires give balance and grip.It includes "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"conveniently placed thumb throttle. Put it all together and you "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGetWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONGetArgs</span><span class="p">{</span><span class="nx">Indent</span><span class="p">:</span> <span class="s">" "</span><span class="p">,</span> <span class="nx">Newline</span><span class="p">:</span> <span class="s">"\n"</span><span class="p">,</span> <span class="nx">Space</span><span class="p">:</span> <span class="s">" "</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// { </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "colors": [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "black", </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "silver" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getmtnbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..mountain_bikes[*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getmodels</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..model"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Salacia","Mimas","Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_get2mtnbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..mountain_bikes[0:2].model"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGetWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONGetArgs</span><span class="p">{</span><span class="nx">Indent</span><span class="p">:</span> <span class="s">" "</span><span class="p">,</span> <span class="nx">Newline</span><span class="p">:</span> <span class="s">"\n"</span><span class="p">,</span> <span class="nx">Space</span><span class="p">:</span> <span class="s">" "</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// { </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "colors": [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "black", </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "white" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ], </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "description": "Redesigned for the 2020 model year </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..[?(@.specs.material == 'alloy')].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Mimas","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter3</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Salacia","Mimas","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter4</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatebikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1475,3941,1920,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1375,3841,1820,1972,3164] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1475,3941,1920,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatefilters1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mi">1500</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1500,3941,1500,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatefilters2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"pink\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [3 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..[*].colors"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["black","silver","pink"],["black","silver","pink"],["black","white"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_json_tutorial-stepfilter4')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_json_tutorial-stepfilter4" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/json_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_json_tutorial-stepfilter4" name="json_tutorial-stepfilter4" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_json_tutorial-stepfilter4" title="Open example"> C# </label> <div aria-labelledby="tab-json_tutorial-stepfilter4" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_json_tutorial-stepfilter4" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.RedisStackCommands</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">Json_tutorial</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\"Hyperion\""</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">JsonType</span><span class="p">[]</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Type</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res3</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; STRING</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_get' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">StrLen</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res4</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 8</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">StrAppend</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">" (Enduro bikes)"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res5</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 23</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'str' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">0</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1.5</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2.5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="p">-</span><span class="m">0.75</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1.75</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'num' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="k">new</span> <span class="kt">object?</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="k">new</span> <span class="p">{</span> <span class="n">crashes</span> <span class="p">=</span> <span class="m">0</span> <span class="p">},</span> <span class="k">null</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$[1].crashes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res13</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [0]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Del</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$.[-1]"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res14</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res15</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="k">new</span> <span class="kt">object</span><span class="p">[]</span> <span class="p">{</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res16</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrAppend</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res17</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res18</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrInsert</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res19</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res20</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem","Prickett","Royce","Castilla"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrTrim</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res21</span><span class="p">));</span> <span class="c1">// 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res22</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span><span class="p">[]</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrPop</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="p">(</span><span class="kt">object</span><span class="p">[])</span><span class="n">res23</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "Prickett"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span><span class="p">[]</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrPop</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="p">(</span><span class="kt">object</span><span class="p">[])</span><span class="n">res24</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; &lt;Empty string&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="p">{</span> <span class="n">model</span> <span class="p">=</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Ergonom"</span><span class="p">,</span> <span class="n">price</span> <span class="p">=</span> <span class="m">4972</span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res25</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ObjLen</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res26</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">IEnumerable</span><span class="p">&lt;</span><span class="n">HashSet</span><span class="p">&lt;</span><span class="kt">string</span><span class="p">&gt;&gt;</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ObjKeys</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res27</span><span class="p">.</span><span class="n">Select</span><span class="p">(</span><span class="n">b</span> <span class="p">=&gt;</span> <span class="s">$"{string.Join("</span><span class="p">,</span> <span class="s">", b.Select(c =&gt; $"</span><span class="p">{</span><span class="n">c</span><span class="p">}</span><span class="s">"))}"</span><span class="p">))</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> <span class="c1">// &gt;&gt;&gt; model, brand, price</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'obj' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">string</span> <span class="n">inventoryJson</span> <span class="p">=</span> <span class="s">@" </span></span></span><span class="line"><span class="cl"><span class="s">{ </span></span></span><span class="line"><span class="cl"><span class="s"> ""inventory"": { </span></span></span><span class="line"><span class="cl"><span class="s"> ""mountain_bikes"": [ </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:1"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Phoebe"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there\u2019s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 1920, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""carbon"", ""weight"": 13.1}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""silver""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:2"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Quaoar"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and tear. All in all it's an impressive package for the price, making it very competitive."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 2072, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""aluminium"", ""weight"": 7.9}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""white""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:3"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Weywot"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 3264, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""alloy"", ""weight"": 13.8} </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s"> ], </span></span></span><span class="line"><span class="cl"><span class="s"> ""commuter_bikes"": [ </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:4"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Salacia"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, this is a bike which doesn\u2019t break the bank and delivers craved performance. It\u2019s for the rider who wants both efficiency and capability."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 1475, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""aluminium"", ""weight"": 16.6}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""silver""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:5"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Mimas"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 3941, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""alloy"", ""weight"": 11.6} </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s"> ] </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s">}"</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">inventoryJson</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res28</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.*"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; {[[{"id":"bike:1","model":"Phoebe", ...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res30</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res32</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res32</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_mtnbikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res33</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res33</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot","Salacia","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_models' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res34</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[0:2].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res34</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get2mtnbikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res35</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res35</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [{"id":"bike:2","model":"Quaoar","description":"Redesigned for the 2020 model year...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter1' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res36</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[?(@.specs.material == 'alloy')].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res36</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Weywot","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res37</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res37</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot","Salacia","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter3' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">bool</span> <span class="n">res38</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line hl"><span class="cl"> <span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res38</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">bool</span> <span class="n">res39</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line hl"><span class="cl"> <span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res39</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">bool</span> <span class="n">res40</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line hl"><span class="cl"> <span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res40</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res41</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span> </span></span><span class="line hl"><span class="cl"> <span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res41</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter4' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res42</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..price"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res42</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res43</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="p">-</span><span class="m">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res43</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1820, 1972, 3164, 1375, 3841</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res44</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res44</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1920, 2072, 3264, 1475, 3941</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res45</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">1500</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res45</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res46</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..price"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res46</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [1500,2072,3264,1500,3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters1' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res47</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrAppend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s">"pink"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res47</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 3, 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res48</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[*].colors"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res48</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["black","silver","pink"],["black","white"],["black","silver","pink"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_json_tutorial-stepfilter4')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_json_tutorial-stepfilter4" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/Json_tutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <h3 id="update-examples"> Update examples </h3> <p> You can also use JSONPath queries when you want to update specific sections of a JSON document. </p> <p> For example, you can pass a JSONPath to the <a href="/docs/latest/commands/json.set/"> <code> JSON.SET </code> </a> command to update a specific field. This example changes the price of the first item in the headphones list: </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="json_tutorial-stepupdate_bikes"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_json_tutorial-stepupdate_bikes" name="json_tutorial-stepupdate_bikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_json_tutorial-stepupdate_bikes" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-json_tutorial-stepupdate_bikes" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_json_tutorial-stepupdate_bikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; JSON.GET bikes:inventory $..price </span></span><span class="line hl"><span class="cl">"[1920,2072,3264,1475,3941]" </span></span><span class="line hl"><span class="cl">&gt; JSON.NUMINCRBY bikes:inventory $..price -100 </span></span><span class="line hl"><span class="cl">"[1820,1972,3164,1375,3841]" </span></span><span class="line hl"><span class="cl">&gt; JSON.NUMINCRBY bikes:inventory $..price 100 </span></span><span class="line hl"><span class="cl">"[1920,2072,3264,1475,3941]"</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_json_tutorial-stepupdate_bikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_json_tutorial-stepupdate_bikes" name="json_tutorial-stepupdate_bikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_json_tutorial-stepupdate_bikes" title="Open example"> Python </label> <div aria-labelledby="tab-json_tutorial-stepupdate_bikes" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_json_tutorial-stepupdate_bikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for JSON doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/json/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s1">'"Hyperion"'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Hyperion"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['string']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">strlen</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [10]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">strappend</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s1">'" (Enduro bikes)"'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 27</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Hyperion"" (Enduro bikes)"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [2.5]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1.75]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"Deimos"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"crashes"</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span> <span class="kc">None</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['["Deimos", { "crashes": 0 }, null]']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$[1].crashes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['0']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$.[-1]"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Deimos', {'crashes': 0}]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrappend</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s2">"Norem"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Norem']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrinsert</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">,</span> <span class="s2">"Royce"</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [4]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Norem', 'Prickett', 'Royce', 'Castilla']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrtrim</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res21</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res22</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res22</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Prickett']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res23</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrpop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res23</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Prickett"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res24</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrpop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res24</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [None]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res25</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Deimos"</span><span class="p">,</span> <span class="s2">"brand"</span><span class="p">:</span> <span class="s2">"Ergonom"</span><span class="p">,</span> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">4972</span><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res25</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res26</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">objlen</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res26</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [3]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">objkeys</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['model', 'brand', 'price']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">inventory_json</span> <span class="o">=</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"inventory"</span><span class="p">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mountain_bikes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This is a mid-travel trail slayer that is a fantastic "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"gives plenty of gear range to tackle hills and there</span><span class="se">\u2019</span><span class="s2">s room for "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mudguards and a rack too. This is the bike for the rider who wants "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"carbon"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"Redesigned for the 2020 model year, this bike "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"impressed our testers and is the best all-around trail bike we've "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"ever tested. The Shimano gear system effectively does away with an "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"external cassette, so is super low maintenance in terms of wear "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"and tear. All in all it's an impressive package for the price, "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"white"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This bike gives kids aged six years and older "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"a durable and uberlight mountain bike for their first experience "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"on tracks and easy cruising through forests and fields. A set of "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"ability. If you're after a budget option, this is one of the best "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"alloy"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="s2">"commuter_bikes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This bike is a great option for anyone who just "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"wants a bike to get about on With a slick-shifting Claris gears "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"from Shimano</span><span class="se">\u2019</span><span class="s2">s, this is a bike which doesn</span><span class="se">\u2019</span><span class="s2">t break the "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bank and delivers craved performance. It</span><span class="se">\u2019</span><span class="s2">s for the rider "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"A real joy to ride, this bike got very high "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"scores in last years Bike of the year report. The carefully "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"Vittoria Zaffiro tires give balance and grip.It includes "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"conveniently placed thumb throttle. Put it all together and you "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"alloy"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="n">inventory_json</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; [[{'id': 'bike:1', 'model': 'Phoebe',</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 'description': 'This is a mid-travel trail slayer...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[*].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s1">'$.inventory["mountain_bikes"][*].model'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..mountain_bikes[*].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot', 'Salacia', 'Mimas']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..mountain_bikes[0:2].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; [{'id': 'bike:2', 'model': 'Quaoar',</span> </span></span><span class="line"><span class="cl"><span class="c1"># 'description': "Redesigned for the 2020 model year...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[?(@.specs.material == 'alloy')].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Weywot', 'Mimas']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Quaoar', 'Weywot', 'Salacia', 'Mimas']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Quaoar', 'Weywot']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1920, 2072, 3264, 1475, 3941]</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1820, 1972, 3164, 1375, 3841]</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1920, 2072, 3264, 1475, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> <span class="mi">1500</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1500, 2072, 3264, 1500, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrappend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s2">"pink"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [3, 3]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[*].colors"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="n">res21</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['black', 'silver', 'pink'], ['black', 'white'], ['black', 'silver', 'pink']]</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_json_tutorial-stepupdate_bikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_json_tutorial-stepupdate_bikes" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_json.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_json_tutorial-stepupdate_bikes" name="json_tutorial-stepupdate_bikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_json_tutorial-stepupdate_bikes" title="Open example"> Node.js </label> <div aria-labelledby="tab-json_tutorial-stepupdate_bikes" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_json_tutorial-stepupdate_bikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">createClient</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s1">'"Hyperion"'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// "Hyperion" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// [ 'string' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">strLen</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// [10] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">strAppend</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s1">'" (Enduro bikes)"'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// 27 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// ['"Hyperion"" (Enduro bikes)"'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"Deimos"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"crashes"</span><span class="o">:</span> <span class="mi">0</span> <span class="p">},</span> <span class="kc">null</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 }, null ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$[1].crashes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 }, null ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$.[-1]"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 } ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrAppend</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s2">"Norem"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">);</span> <span class="c1">// [ 'Norem' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrInsert</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">,</span> <span class="s2">"Royse"</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">);</span> <span class="c1">// [4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">);</span> <span class="c1">// [ 'Norem', 'Prickett', 'Royse', 'Castilla' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrTrim</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">);</span> <span class="c1">// [ 'Prickett' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res23</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrPop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res23</span><span class="p">);</span> <span class="c1">// [ 'Prickett' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res24</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrPop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res24</span><span class="p">);</span> <span class="c1">// [null] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res25</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"brand"</span><span class="o">:</span> <span class="s2">"Ergonom"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">4972</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res25</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res26</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">objLen</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res26</span><span class="p">);</span> <span class="c1">// [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">objKeys</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27</span><span class="p">);</span> <span class="c1">// [['model', 'brand', 'price']] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">inventoryJSON</span> <span class="o">=</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"inventory"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mountain_bikes"</span><span class="o">:</span> <span class="p">[{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there\u2019s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"carbon"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">13.1</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">7.9</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"white"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"alloy"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">13.8</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="s2">"commuter_bikes"</span><span class="o">:</span> <span class="p">[{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, this is a bike which doesn\u2019t break the bank and delivers craved performance. It\u2019s for the rider who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">16.6</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"alloy"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">11.6</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">};</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="nx">inventoryJSON</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$.inventory.*"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="cm">/* </span></span></span><span class="line"><span class="cl"><span class="cm">[ </span></span></span><span class="line"><span class="cl"><span class="cm"> [ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:1', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Phoebe', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there’s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 1920, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:2', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Quaoar', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 2072, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:3', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Weywot', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 3264, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm"> ], </span></span></span><span class="line"><span class="cl"><span class="cm"> [ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:4', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Salacia', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano’s, this is a bike which doesn’t break the bank and delivers craved performance. It’s for the rider who wants both efficiency and capability.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 1475, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:5', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Mimas', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 3941, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm"> ] </span></span></span><span class="line"><span class="cl"><span class="cm">] </span></span></span><span class="line"><span class="cl"><span class="cm">*/</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res30</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$.inventory.mountain_bikes[*].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res30</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res31</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s1">'$.inventory["mountain_bikes"][*].model'</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res31</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res32</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[*].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res32</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res33</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res33</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot', 'Salacia', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res34</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[0:2].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res34</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res35</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res35</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="cm">/* </span></span></span><span class="line"><span class="cl"><span class="cm">[ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:2', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Quaoar', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 2072, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: { material: 'aluminium', weight: 7.9 }, </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [ 'black', 'white' ] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm">] </span></span></span><span class="line"><span class="cl"><span class="cm">*/</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1">// names of bikes made from an alloy </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res36</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[?(@.specs.material == 'alloy')].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// ['Weywot', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[?(@.specs.material =~ '(?i)al')].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37</span><span class="p">);</span> <span class="c1">// ['Quaoar', 'Weywot', 'Salacia', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37a</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[0].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37b</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[1].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37c</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[2].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37d</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37d</span><span class="p">);</span> <span class="c1">// ['Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res38</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..price"</span> </span></span><span class="line hl"><span class="cl"><span class="p">});</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res38</span><span class="p">);</span> <span class="c1">// [1920, 2072, 3264, 1475, 3941] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res39</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res39</span><span class="p">);</span> <span class="c1">// [1820, 1972, 3164, 1375, 3841] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res40</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40</span><span class="p">);</span> <span class="c1">// [1920, 2072, 3264, 1475, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40a</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.*[?(@.price&lt;2000)].price'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mi">1500</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1">// Get all prices from the inventory </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res40b</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$..price'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40b</span><span class="p">);</span> <span class="c1">// [1500, 2072, 3264, 1500, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res41</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrAppend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s2">"pink"</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res41</span><span class="p">);</span> <span class="c1">// [3, 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res42</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[*].colors"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res42</span><span class="p">);</span> <span class="c1">// [['black', 'silver', 'pink'], ['black', 'white'], ['black', 'silver', 'pink']] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_json_tutorial-stepupdate_bikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_json_tutorial-stepupdate_bikes" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-json.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_json_tutorial-stepupdate_bikes" name="json_tutorial-stepupdate_bikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_json_tutorial-stepupdate_bikes" title="Open example"> Java </label> <div aria-labelledby="tab-json_tutorial-stepupdate_bikes" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_json_tutorial-stepupdate_bikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.json.Path2</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.json.JSONArray</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.json.JSONObject</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">JsonExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">"\"Hyperion\""</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Class</span><span class="o">&lt;?&gt;&gt;</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonType</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [class java.lang.String] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_get' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonStrLen</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [8] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonStrAppend</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">" (Enduro bikes)"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [23] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'str' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">0</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mf">1.5</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="o">-</span><span class="mf">0.75</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'num' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">JSONArray</span><span class="o">()</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"Deimos"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="k">new</span> <span class="n">JSONObject</span><span class="o">().</span><span class="na">put</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="mi">0</span><span class="o">))</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">((</span><span class="n">Object</span><span class="o">)</span> <span class="kc">null</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$[1].crashes"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [0] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonDel</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.[-1]"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="k">new</span> <span class="n">JSONArray</span><span class="o">());</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrAppendWithEscape</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">"Norem"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrInsertWithEscape</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">,</span> <span class="s">"Prickett"</span><span class="o">,</span> <span class="s">"Royce"</span><span class="o">,</span> <span class="s">"Castilla"</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res19</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["Norem","Prickett","Royce","Castilla"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrTrim</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">,</span> <span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res23</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrPop</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res23</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [Prickett] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res24</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrPop</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res24</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [null] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res25</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">JSONObject</span><span class="o">()</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"model"</span><span class="o">,</span> <span class="s">"Deimos"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"brand"</span><span class="o">,</span> <span class="s">"Ergonom"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"price"</span><span class="o">,</span> <span class="mi">4972</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res25</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res26</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonObjLen</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res26</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;&gt;</span> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonObjKeys</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [[price, model, brand]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'obj' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">inventory_json</span> <span class="o">=</span> <span class="s">"{"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"inventory\": {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"mountain_bikes\": ["</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:1\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Phoebe\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This is a mid-travel trail slayer that is a "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for mudguards "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and a rack too. This is the bike for the rider who wants trail manners with "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"low fuss ownership.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1920,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"carbon\", \"weight\": 13.1},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"silver\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:2\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Quaoar\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"Redesigned for the 2020 model year, this "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"bike impressed our testers and is the best all-around trail bike we've ever "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"tested. The Shimano gear system effectively does away with an external cassette, "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"so is super low maintenance in terms of wear and tear. All in all it's an "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"impressive package for the price, making it very competitive.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 2072,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"aluminium\", \"weight\": 7.9},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"white\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:3\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Weywot\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This bike gives kids aged six years and older "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"a durable and uberlight mountain bike for their first experience on tracks and easy "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"provide ample stopping ability. If you're after a budget option, this is one of the "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"best bikes you could get.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3264,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"alloy\", \"weight\": 13.8}"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" ],"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"commuter_bikes\": ["</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:4\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Salacia\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This bike is a great option for anyone who just "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"this is a bike which doesn\u2019t break the bank and delivers craved performance. "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"It\u2019s for the rider who wants both efficiency and capability.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1475,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"aluminium\", \"weight\": 16.6},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"silver\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:5\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Mimas\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"A real joy to ride, this bike got very high scores "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"in last years Bike of the year report. The carefully crafted 50-34 tooth chainset "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"throttle. Put it all together and you get a bike that helps redefine what can be "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"done for this price.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3941,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"alloy\", \"weight\": 11.6}"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" ]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"}"</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="n">inventory_json</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res28</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [[{"specs":{"material":"carbon","weight":13.1},"price":1920, ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res30</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res30</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res31</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res31</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res32</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res32</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_mtnbikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res33</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..model"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res33</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot","Salacia","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_models' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res34</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[0:2].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res34</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get2mtnbikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res35</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res35</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [{"specs":{"material":"aluminium","weight":7.9},"price":2072,... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter1' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res36</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[?(@.specs.material == 'alloy')].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Weywot","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res37</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res37</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot","Salacia","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter3' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res38</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res38</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter4' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">Object</span> <span class="n">res39</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">));</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res39</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">Object</span> <span class="n">res40</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">),</span> <span class="o">-</span><span class="mi">100</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res40</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1820,1972,3164,1375,3841] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">Object</span> <span class="n">res41</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">),</span> <span class="mi">100</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res41</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="o">),</span> <span class="mi">1500</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res42</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res42</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1500,2072,3264,1500,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters1' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res43</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrAppendWithEscape</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"pink\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res43</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [3, 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res44</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[*].colors"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res44</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["black","silver","\"pink\""],["black","white"],["black","silver","\"pink\""]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">close</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_json_tutorial-stepupdate_bikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_json_tutorial-stepupdate_bikes" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/JsonExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_json_tutorial-stepupdate_bikes" name="json_tutorial-stepupdate_bikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_json_tutorial-stepupdate_bikes" title="Open example"> Go </label> <div aria-labelledby="tab-json_tutorial-stepupdate_bikes" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_json_tutorial-stepupdate_bikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_setget</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Hyperion\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONType</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [[string]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_str</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Hyperion\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONStrLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res4</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 8 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONStrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\" (Enduro bikes)\""</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res5</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 23 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_num</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_arr</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"crashes"</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kc">nil</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$[1].crashes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [0] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONDel</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$.[-1]"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_arr2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{}).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\"Norem\""</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrInsert</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Prickett\""</span><span class="p">,</span> <span class="s">"\"Royce\""</span><span class="p">,</span> <span class="s">"\"Castilla\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Norem", "Prickett", "Royce", "Castilla"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">rangeStop</span> <span class="o">:=</span> <span class="mi">1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrTrimWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONArrTrimArgs</span><span class="p">{</span><span class="nx">Start</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">Stop</span><span class="p">:</span> <span class="o">&amp;</span><span class="nx">rangeStop</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res23</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res23</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res24</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res24</span><span class="p">)</span> <span class="c1">// [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_obj</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res25</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"brand"</span><span class="p">:</span> <span class="s">"Ergonom"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">4972</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res25</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res26</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONObjLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res26</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res27</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONObjKeys</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res27</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [brand model price] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">var</span> <span class="nx">inventory_json</span> <span class="p">=</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"inventory"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"mountain_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This is a mid-travel trail slayer that is a fantastic "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"mudguards and a rack too. This is the bike for the rider who wants "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"carbon"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"Redesigned for the 2020 model year, this bike "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"impressed our testers and is the best all-around trail bike we've "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ever tested. The Shimano gear system effectively does away with an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"external cassette, so is super low maintenance in terms of wear "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"and tear. All in all it's an impressive package for the price, "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"white"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike gives kids aged six years and older "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a durable and uberlight mountain bike for their first experience "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"on tracks and easy cruising through forests and fields. A set of "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ability. If you're after a budget option, this is one of the best "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"commuter_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike is a great option for anyone who just "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"from Shimano\u2019s, this is a bike which doesn\u2019t break the "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bank and delivers craved performance. It\u2019s for the rider "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"A real joy to ride, this bike got very high "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"scores in last years Bike of the year report. The carefully "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"Vittoria Zaffiro tires give balance and grip.It includes "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"conveniently placed thumb throttle. Put it all together and you "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_setbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kd">var</span> <span class="nx">inventory_json</span> <span class="p">=</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"inventory"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"mountain_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This is a mid-travel trail slayer that is a fantastic "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"mudguards and a rack too. This is the bike for the rider who wants "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"carbon"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"Redesigned for the 2020 model year, this bike "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"impressed our testers and is the best all-around trail bike we've "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ever tested. The Shimano gear system effectively does away with an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"external cassette, so is super low maintenance in terms of wear "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"and tear. All in all it's an impressive package for the price, "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"white"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike gives kids aged six years and older "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a durable and uberlight mountain bike for their first experience "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"on tracks and easy cruising through forests and fields. A set of "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ability. If you're after a budget option, this is one of the best "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"commuter_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike is a great option for anyone who just "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"from Shimano\u2019s, this is a bike which doesn\u2019t break the "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bank and delivers craved performance. It\u2019s for the rider "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"A real joy to ride, this bike got very high "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"scores in last years Bike of the year report. The carefully "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"Vittoria Zaffiro tires give balance and grip.It includes "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"conveniently placed thumb throttle. Put it all together and you "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGetWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONGetArgs</span><span class="p">{</span><span class="nx">Indent</span><span class="p">:</span> <span class="s">" "</span><span class="p">,</span> <span class="nx">Newline</span><span class="p">:</span> <span class="s">"\n"</span><span class="p">,</span> <span class="nx">Space</span><span class="p">:</span> <span class="s">" "</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// { </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "colors": [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "black", </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "silver" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getmtnbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..mountain_bikes[*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getmodels</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..model"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Salacia","Mimas","Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_get2mtnbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..mountain_bikes[0:2].model"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGetWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONGetArgs</span><span class="p">{</span><span class="nx">Indent</span><span class="p">:</span> <span class="s">" "</span><span class="p">,</span> <span class="nx">Newline</span><span class="p">:</span> <span class="s">"\n"</span><span class="p">,</span> <span class="nx">Space</span><span class="p">:</span> <span class="s">" "</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// { </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "colors": [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "black", </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "white" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ], </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "description": "Redesigned for the 2020 model year </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..[?(@.specs.material == 'alloy')].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Mimas","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter3</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Salacia","Mimas","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter4</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatebikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1475,3941,1920,2072,3264] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1375,3841,1820,1972,3164] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1475,3941,1920,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatefilters1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mi">1500</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1500,3941,1500,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatefilters2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"pink\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [3 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..[*].colors"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["black","silver","pink"],["black","silver","pink"],["black","white"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_json_tutorial-stepupdate_bikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_json_tutorial-stepupdate_bikes" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/json_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_json_tutorial-stepupdate_bikes" name="json_tutorial-stepupdate_bikes" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_json_tutorial-stepupdate_bikes" title="Open example"> C# </label> <div aria-labelledby="tab-json_tutorial-stepupdate_bikes" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_json_tutorial-stepupdate_bikes" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.RedisStackCommands</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">Json_tutorial</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\"Hyperion\""</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">JsonType</span><span class="p">[]</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Type</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res3</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; STRING</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_get' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">StrLen</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res4</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 8</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">StrAppend</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">" (Enduro bikes)"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res5</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 23</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'str' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">0</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1.5</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2.5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="p">-</span><span class="m">0.75</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1.75</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'num' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="k">new</span> <span class="kt">object?</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="k">new</span> <span class="p">{</span> <span class="n">crashes</span> <span class="p">=</span> <span class="m">0</span> <span class="p">},</span> <span class="k">null</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$[1].crashes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res13</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [0]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Del</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$.[-1]"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res14</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res15</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="k">new</span> <span class="kt">object</span><span class="p">[]</span> <span class="p">{</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res16</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrAppend</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res17</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res18</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrInsert</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res19</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res20</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem","Prickett","Royce","Castilla"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrTrim</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res21</span><span class="p">));</span> <span class="c1">// 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res22</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span><span class="p">[]</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrPop</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="p">(</span><span class="kt">object</span><span class="p">[])</span><span class="n">res23</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "Prickett"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span><span class="p">[]</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrPop</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="p">(</span><span class="kt">object</span><span class="p">[])</span><span class="n">res24</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; &lt;Empty string&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="p">{</span> <span class="n">model</span> <span class="p">=</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Ergonom"</span><span class="p">,</span> <span class="n">price</span> <span class="p">=</span> <span class="m">4972</span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res25</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ObjLen</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res26</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">IEnumerable</span><span class="p">&lt;</span><span class="n">HashSet</span><span class="p">&lt;</span><span class="kt">string</span><span class="p">&gt;&gt;</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ObjKeys</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res27</span><span class="p">.</span><span class="n">Select</span><span class="p">(</span><span class="n">b</span> <span class="p">=&gt;</span> <span class="s">$"{string.Join("</span><span class="p">,</span> <span class="s">", b.Select(c =&gt; $"</span><span class="p">{</span><span class="n">c</span><span class="p">}</span><span class="s">"))}"</span><span class="p">))</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> <span class="c1">// &gt;&gt;&gt; model, brand, price</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'obj' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">string</span> <span class="n">inventoryJson</span> <span class="p">=</span> <span class="s">@" </span></span></span><span class="line"><span class="cl"><span class="s">{ </span></span></span><span class="line"><span class="cl"><span class="s"> ""inventory"": { </span></span></span><span class="line"><span class="cl"><span class="s"> ""mountain_bikes"": [ </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:1"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Phoebe"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there\u2019s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 1920, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""carbon"", ""weight"": 13.1}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""silver""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:2"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Quaoar"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and tear. All in all it's an impressive package for the price, making it very competitive."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 2072, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""aluminium"", ""weight"": 7.9}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""white""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:3"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Weywot"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 3264, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""alloy"", ""weight"": 13.8} </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s"> ], </span></span></span><span class="line"><span class="cl"><span class="s"> ""commuter_bikes"": [ </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:4"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Salacia"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, this is a bike which doesn\u2019t break the bank and delivers craved performance. It\u2019s for the rider who wants both efficiency and capability."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 1475, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""aluminium"", ""weight"": 16.6}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""silver""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:5"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Mimas"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 3941, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""alloy"", ""weight"": 11.6} </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s"> ] </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s">}"</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">inventoryJson</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res28</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.*"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; {[[{"id":"bike:1","model":"Phoebe", ...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res30</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res32</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res32</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_mtnbikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res33</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res33</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot","Salacia","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_models' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res34</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[0:2].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res34</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get2mtnbikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res35</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res35</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [{"id":"bike:2","model":"Quaoar","description":"Redesigned for the 2020 model year...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter1' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res36</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[?(@.specs.material == 'alloy')].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res36</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Weywot","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res37</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res37</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot","Salacia","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter3' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res38</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res38</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res39</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res39</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res40</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res40</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res41</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res41</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter4' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res42</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..price"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res42</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941]</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res43</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="p">-</span><span class="m">100</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res43</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1820, 1972, 3164, 1375, 3841</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res44</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res44</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1920, 2072, 3264, 1475, 3941</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res45</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">1500</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res45</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res46</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..price"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res46</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [1500,2072,3264,1500,3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters1' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res47</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrAppend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s">"pink"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res47</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 3, 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res48</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[*].colors"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res48</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["black","silver","pink"],["black","white"],["black","silver","pink"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_json_tutorial-stepupdate_bikes')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_json_tutorial-stepupdate_bikes" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/Json_tutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> You can use filter expressions to update only JSON elements that match certain conditions. The following example sets the price of any bike to 1500 if its price is already less than 2000: </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="json_tutorial-stepupdate_filters1"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_json_tutorial-stepupdate_filters1" name="json_tutorial-stepupdate_filters1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_json_tutorial-stepupdate_filters1" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-json_tutorial-stepupdate_filters1" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_json_tutorial-stepupdate_filters1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; JSON.SET bikes:inventory '$.inventory.*[?(@.price&lt;2000)].price' 1500 </span></span><span class="line hl"><span class="cl">OK </span></span><span class="line hl"><span class="cl">&gt; JSON.GET bikes:inventory $..price </span></span><span class="line hl"><span class="cl">"[1500,2072,3264,1500,3941]"</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_json_tutorial-stepupdate_filters1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_json_tutorial-stepupdate_filters1" name="json_tutorial-stepupdate_filters1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_json_tutorial-stepupdate_filters1" title="Open example"> Python </label> <div aria-labelledby="tab-json_tutorial-stepupdate_filters1" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_json_tutorial-stepupdate_filters1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for JSON doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/json/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s1">'"Hyperion"'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Hyperion"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['string']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">strlen</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [10]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">strappend</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s1">'" (Enduro bikes)"'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 27</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Hyperion"" (Enduro bikes)"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [2.5]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1.75]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"Deimos"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"crashes"</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span> <span class="kc">None</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['["Deimos", { "crashes": 0 }, null]']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$[1].crashes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['0']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$.[-1]"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Deimos', {'crashes': 0}]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrappend</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s2">"Norem"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Norem']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrinsert</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">,</span> <span class="s2">"Royce"</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [4]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Norem', 'Prickett', 'Royce', 'Castilla']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrtrim</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res21</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res22</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res22</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Prickett']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res23</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrpop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res23</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Prickett"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res24</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrpop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res24</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [None]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res25</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Deimos"</span><span class="p">,</span> <span class="s2">"brand"</span><span class="p">:</span> <span class="s2">"Ergonom"</span><span class="p">,</span> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">4972</span><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res25</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res26</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">objlen</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res26</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [3]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">objkeys</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['model', 'brand', 'price']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">inventory_json</span> <span class="o">=</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"inventory"</span><span class="p">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mountain_bikes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This is a mid-travel trail slayer that is a fantastic "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"gives plenty of gear range to tackle hills and there</span><span class="se">\u2019</span><span class="s2">s room for "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mudguards and a rack too. This is the bike for the rider who wants "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"carbon"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"Redesigned for the 2020 model year, this bike "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"impressed our testers and is the best all-around trail bike we've "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"ever tested. The Shimano gear system effectively does away with an "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"external cassette, so is super low maintenance in terms of wear "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"and tear. All in all it's an impressive package for the price, "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"white"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This bike gives kids aged six years and older "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"a durable and uberlight mountain bike for their first experience "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"on tracks and easy cruising through forests and fields. A set of "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"ability. If you're after a budget option, this is one of the best "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"alloy"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="s2">"commuter_bikes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This bike is a great option for anyone who just "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"wants a bike to get about on With a slick-shifting Claris gears "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"from Shimano</span><span class="se">\u2019</span><span class="s2">s, this is a bike which doesn</span><span class="se">\u2019</span><span class="s2">t break the "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bank and delivers craved performance. It</span><span class="se">\u2019</span><span class="s2">s for the rider "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"A real joy to ride, this bike got very high "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"scores in last years Bike of the year report. The carefully "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"Vittoria Zaffiro tires give balance and grip.It includes "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"conveniently placed thumb throttle. Put it all together and you "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"alloy"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="n">inventory_json</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; [[{'id': 'bike:1', 'model': 'Phoebe',</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 'description': 'This is a mid-travel trail slayer...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[*].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s1">'$.inventory["mountain_bikes"][*].model'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..mountain_bikes[*].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot', 'Salacia', 'Mimas']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..mountain_bikes[0:2].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; [{'id': 'bike:2', 'model': 'Quaoar',</span> </span></span><span class="line"><span class="cl"><span class="c1"># 'description': "Redesigned for the 2020 model year...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[?(@.specs.material == 'alloy')].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Weywot', 'Mimas']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Quaoar', 'Weywot', 'Salacia', 'Mimas']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Quaoar', 'Weywot']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1920, 2072, 3264, 1475, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1820, 1972, 3164, 1375, 3841]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1920, 2072, 3264, 1475, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> <span class="mi">1500</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1500, 2072, 3264, 1500, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrappend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s2">"pink"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [3, 3]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[*].colors"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="n">res21</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['black', 'silver', 'pink'], ['black', 'white'], ['black', 'silver', 'pink']]</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_json_tutorial-stepupdate_filters1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_json_tutorial-stepupdate_filters1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_json.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_json_tutorial-stepupdate_filters1" name="json_tutorial-stepupdate_filters1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_json_tutorial-stepupdate_filters1" title="Open example"> Node.js </label> <div aria-labelledby="tab-json_tutorial-stepupdate_filters1" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_json_tutorial-stepupdate_filters1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">createClient</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s1">'"Hyperion"'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// "Hyperion" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// [ 'string' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">strLen</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// [10] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">strAppend</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s1">'" (Enduro bikes)"'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// 27 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// ['"Hyperion"" (Enduro bikes)"'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"Deimos"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"crashes"</span><span class="o">:</span> <span class="mi">0</span> <span class="p">},</span> <span class="kc">null</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 }, null ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$[1].crashes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 }, null ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$.[-1]"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 } ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrAppend</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s2">"Norem"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">);</span> <span class="c1">// [ 'Norem' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrInsert</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">,</span> <span class="s2">"Royse"</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">);</span> <span class="c1">// [4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">);</span> <span class="c1">// [ 'Norem', 'Prickett', 'Royse', 'Castilla' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrTrim</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">);</span> <span class="c1">// [ 'Prickett' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res23</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrPop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res23</span><span class="p">);</span> <span class="c1">// [ 'Prickett' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res24</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrPop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res24</span><span class="p">);</span> <span class="c1">// [null] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res25</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"brand"</span><span class="o">:</span> <span class="s2">"Ergonom"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">4972</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res25</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res26</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">objLen</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res26</span><span class="p">);</span> <span class="c1">// [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">objKeys</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27</span><span class="p">);</span> <span class="c1">// [['model', 'brand', 'price']] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">inventoryJSON</span> <span class="o">=</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"inventory"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mountain_bikes"</span><span class="o">:</span> <span class="p">[{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there\u2019s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"carbon"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">13.1</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">7.9</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"white"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"alloy"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">13.8</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="s2">"commuter_bikes"</span><span class="o">:</span> <span class="p">[{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, this is a bike which doesn\u2019t break the bank and delivers craved performance. It\u2019s for the rider who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">16.6</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"alloy"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">11.6</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">};</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="nx">inventoryJSON</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$.inventory.*"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="cm">/* </span></span></span><span class="line"><span class="cl"><span class="cm">[ </span></span></span><span class="line"><span class="cl"><span class="cm"> [ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:1', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Phoebe', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there’s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 1920, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:2', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Quaoar', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 2072, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:3', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Weywot', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 3264, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm"> ], </span></span></span><span class="line"><span class="cl"><span class="cm"> [ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:4', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Salacia', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano’s, this is a bike which doesn’t break the bank and delivers craved performance. It’s for the rider who wants both efficiency and capability.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 1475, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:5', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Mimas', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 3941, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm"> ] </span></span></span><span class="line"><span class="cl"><span class="cm">] </span></span></span><span class="line"><span class="cl"><span class="cm">*/</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res30</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$.inventory.mountain_bikes[*].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res30</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res31</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s1">'$.inventory["mountain_bikes"][*].model'</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res31</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res32</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[*].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res32</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res33</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res33</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot', 'Salacia', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res34</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[0:2].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res34</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res35</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res35</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="cm">/* </span></span></span><span class="line"><span class="cl"><span class="cm">[ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:2', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Quaoar', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 2072, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: { material: 'aluminium', weight: 7.9 }, </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [ 'black', 'white' ] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm">] </span></span></span><span class="line"><span class="cl"><span class="cm">*/</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1">// names of bikes made from an alloy </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res36</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[?(@.specs.material == 'alloy')].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// ['Weywot', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[?(@.specs.material =~ '(?i)al')].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37</span><span class="p">);</span> <span class="c1">// ['Quaoar', 'Weywot', 'Salacia', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37a</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[0].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37b</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[1].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37c</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[2].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37d</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37d</span><span class="p">);</span> <span class="c1">// ['Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res38</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..price"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res38</span><span class="p">);</span> <span class="c1">// [1920, 2072, 3264, 1475, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res39</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res39</span><span class="p">);</span> <span class="c1">// [1820, 1972, 3164, 1375, 3841] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40</span><span class="p">);</span> <span class="c1">// [1920, 2072, 3264, 1475, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res40a</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s1">'$.inventory.*[?(@.price&lt;2000)].price'</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="mi">1500</span> </span></span><span class="line hl"><span class="cl"><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="c1">// Get all prices from the inventory </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res40b</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s1">'$..price'</span> </span></span><span class="line hl"><span class="cl"><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40b</span><span class="p">);</span> <span class="c1">// [1500, 2072, 3264, 1500, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res41</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrAppend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s2">"pink"</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res41</span><span class="p">);</span> <span class="c1">// [3, 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res42</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[*].colors"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res42</span><span class="p">);</span> <span class="c1">// [['black', 'silver', 'pink'], ['black', 'white'], ['black', 'silver', 'pink']] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_json_tutorial-stepupdate_filters1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_json_tutorial-stepupdate_filters1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-json.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_json_tutorial-stepupdate_filters1" name="json_tutorial-stepupdate_filters1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_json_tutorial-stepupdate_filters1" title="Open example"> Java </label> <div aria-labelledby="tab-json_tutorial-stepupdate_filters1" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_json_tutorial-stepupdate_filters1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.json.Path2</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.json.JSONArray</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.json.JSONObject</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">JsonExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">"\"Hyperion\""</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Class</span><span class="o">&lt;?&gt;&gt;</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonType</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [class java.lang.String] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_get' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonStrLen</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [8] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonStrAppend</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">" (Enduro bikes)"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [23] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'str' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">0</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mf">1.5</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="o">-</span><span class="mf">0.75</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'num' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">JSONArray</span><span class="o">()</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"Deimos"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="k">new</span> <span class="n">JSONObject</span><span class="o">().</span><span class="na">put</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="mi">0</span><span class="o">))</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">((</span><span class="n">Object</span><span class="o">)</span> <span class="kc">null</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$[1].crashes"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [0] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonDel</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.[-1]"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="k">new</span> <span class="n">JSONArray</span><span class="o">());</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrAppendWithEscape</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">"Norem"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrInsertWithEscape</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">,</span> <span class="s">"Prickett"</span><span class="o">,</span> <span class="s">"Royce"</span><span class="o">,</span> <span class="s">"Castilla"</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res19</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["Norem","Prickett","Royce","Castilla"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrTrim</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">,</span> <span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res23</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrPop</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res23</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [Prickett] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res24</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrPop</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res24</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [null] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res25</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">JSONObject</span><span class="o">()</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"model"</span><span class="o">,</span> <span class="s">"Deimos"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"brand"</span><span class="o">,</span> <span class="s">"Ergonom"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"price"</span><span class="o">,</span> <span class="mi">4972</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res25</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res26</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonObjLen</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res26</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;&gt;</span> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonObjKeys</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [[price, model, brand]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'obj' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">inventory_json</span> <span class="o">=</span> <span class="s">"{"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"inventory\": {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"mountain_bikes\": ["</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:1\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Phoebe\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This is a mid-travel trail slayer that is a "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for mudguards "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and a rack too. This is the bike for the rider who wants trail manners with "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"low fuss ownership.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1920,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"carbon\", \"weight\": 13.1},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"silver\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:2\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Quaoar\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"Redesigned for the 2020 model year, this "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"bike impressed our testers and is the best all-around trail bike we've ever "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"tested. The Shimano gear system effectively does away with an external cassette, "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"so is super low maintenance in terms of wear and tear. All in all it's an "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"impressive package for the price, making it very competitive.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 2072,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"aluminium\", \"weight\": 7.9},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"white\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:3\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Weywot\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This bike gives kids aged six years and older "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"a durable and uberlight mountain bike for their first experience on tracks and easy "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"provide ample stopping ability. If you're after a budget option, this is one of the "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"best bikes you could get.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3264,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"alloy\", \"weight\": 13.8}"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" ],"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"commuter_bikes\": ["</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:4\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Salacia\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This bike is a great option for anyone who just "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"this is a bike which doesn\u2019t break the bank and delivers craved performance. "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"It\u2019s for the rider who wants both efficiency and capability.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1475,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"aluminium\", \"weight\": 16.6},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"silver\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:5\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Mimas\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"A real joy to ride, this bike got very high scores "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"in last years Bike of the year report. The carefully crafted 50-34 tooth chainset "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"throttle. Put it all together and you get a bike that helps redefine what can be "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"done for this price.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3941,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"alloy\", \"weight\": 11.6}"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" ]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"}"</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="n">inventory_json</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res28</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [[{"specs":{"material":"carbon","weight":13.1},"price":1920, ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res30</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res30</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res31</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res31</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res32</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res32</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_mtnbikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res33</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..model"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res33</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot","Salacia","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_models' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res34</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[0:2].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res34</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get2mtnbikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res35</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res35</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [{"specs":{"material":"aluminium","weight":7.9},"price":2072,... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter1' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res36</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[?(@.specs.material == 'alloy')].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Weywot","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res37</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res37</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot","Salacia","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter3' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res38</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res38</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter4' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res39</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res39</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res40</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">),</span> <span class="o">-</span><span class="mi">100</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res40</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1820,1972,3164,1375,3841] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res41</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">),</span> <span class="mi">100</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res41</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="o">),</span> <span class="mi">1500</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Object</span> <span class="n">res42</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">));</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res42</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1500,2072,3264,1500,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters1' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res43</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrAppendWithEscape</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"pink\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res43</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [3, 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res44</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[*].colors"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res44</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["black","silver","\"pink\""],["black","white"],["black","silver","\"pink\""]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">close</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_json_tutorial-stepupdate_filters1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_json_tutorial-stepupdate_filters1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/JsonExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_json_tutorial-stepupdate_filters1" name="json_tutorial-stepupdate_filters1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_json_tutorial-stepupdate_filters1" title="Open example"> Go </label> <div aria-labelledby="tab-json_tutorial-stepupdate_filters1" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_json_tutorial-stepupdate_filters1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_setget</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Hyperion\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONType</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [[string]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_str</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Hyperion\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONStrLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res4</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 8 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONStrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\" (Enduro bikes)\""</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res5</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 23 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_num</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_arr</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"crashes"</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kc">nil</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$[1].crashes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [0] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONDel</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$.[-1]"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_arr2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{}).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\"Norem\""</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrInsert</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Prickett\""</span><span class="p">,</span> <span class="s">"\"Royce\""</span><span class="p">,</span> <span class="s">"\"Castilla\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Norem", "Prickett", "Royce", "Castilla"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">rangeStop</span> <span class="o">:=</span> <span class="mi">1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrTrimWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONArrTrimArgs</span><span class="p">{</span><span class="nx">Start</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">Stop</span><span class="p">:</span> <span class="o">&amp;</span><span class="nx">rangeStop</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res23</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res23</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res24</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res24</span><span class="p">)</span> <span class="c1">// [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_obj</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res25</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"brand"</span><span class="p">:</span> <span class="s">"Ergonom"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">4972</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res25</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res26</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONObjLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res26</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res27</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONObjKeys</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res27</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [brand model price] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">var</span> <span class="nx">inventory_json</span> <span class="p">=</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"inventory"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"mountain_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This is a mid-travel trail slayer that is a fantastic "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"mudguards and a rack too. This is the bike for the rider who wants "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"carbon"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"Redesigned for the 2020 model year, this bike "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"impressed our testers and is the best all-around trail bike we've "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ever tested. The Shimano gear system effectively does away with an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"external cassette, so is super low maintenance in terms of wear "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"and tear. All in all it's an impressive package for the price, "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"white"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike gives kids aged six years and older "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a durable and uberlight mountain bike for their first experience "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"on tracks and easy cruising through forests and fields. A set of "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ability. If you're after a budget option, this is one of the best "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"commuter_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike is a great option for anyone who just "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"from Shimano\u2019s, this is a bike which doesn\u2019t break the "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bank and delivers craved performance. It\u2019s for the rider "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"A real joy to ride, this bike got very high "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"scores in last years Bike of the year report. The carefully "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"Vittoria Zaffiro tires give balance and grip.It includes "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"conveniently placed thumb throttle. Put it all together and you "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_setbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kd">var</span> <span class="nx">inventory_json</span> <span class="p">=</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"inventory"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"mountain_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This is a mid-travel trail slayer that is a fantastic "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"mudguards and a rack too. This is the bike for the rider who wants "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"carbon"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"Redesigned for the 2020 model year, this bike "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"impressed our testers and is the best all-around trail bike we've "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ever tested. The Shimano gear system effectively does away with an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"external cassette, so is super low maintenance in terms of wear "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"and tear. All in all it's an impressive package for the price, "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"white"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike gives kids aged six years and older "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a durable and uberlight mountain bike for their first experience "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"on tracks and easy cruising through forests and fields. A set of "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ability. If you're after a budget option, this is one of the best "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"commuter_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike is a great option for anyone who just "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"from Shimano\u2019s, this is a bike which doesn\u2019t break the "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bank and delivers craved performance. It\u2019s for the rider "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"A real joy to ride, this bike got very high "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"scores in last years Bike of the year report. The carefully "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"Vittoria Zaffiro tires give balance and grip.It includes "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"conveniently placed thumb throttle. Put it all together and you "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGetWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONGetArgs</span><span class="p">{</span><span class="nx">Indent</span><span class="p">:</span> <span class="s">" "</span><span class="p">,</span> <span class="nx">Newline</span><span class="p">:</span> <span class="s">"\n"</span><span class="p">,</span> <span class="nx">Space</span><span class="p">:</span> <span class="s">" "</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// { </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "colors": [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "black", </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "silver" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getmtnbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..mountain_bikes[*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getmodels</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..model"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Salacia","Mimas","Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_get2mtnbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..mountain_bikes[0:2].model"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGetWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONGetArgs</span><span class="p">{</span><span class="nx">Indent</span><span class="p">:</span> <span class="s">" "</span><span class="p">,</span> <span class="nx">Newline</span><span class="p">:</span> <span class="s">"\n"</span><span class="p">,</span> <span class="nx">Space</span><span class="p">:</span> <span class="s">" "</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// { </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "colors": [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "black", </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "white" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ], </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "description": "Redesigned for the 2020 model year </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..[?(@.specs.material == 'alloy')].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Mimas","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter3</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Salacia","Mimas","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter4</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatebikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1475,3941,1920,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1375,3841,1820,1972,3164] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1475,3941,1920,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatefilters1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="mi">1500</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1500,3941,1500,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatefilters2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"pink\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [3 3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..[*].colors"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["black","silver","pink"],["black","silver","pink"],["black","white"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_json_tutorial-stepupdate_filters1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_json_tutorial-stepupdate_filters1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/json_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_json_tutorial-stepupdate_filters1" name="json_tutorial-stepupdate_filters1" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_json_tutorial-stepupdate_filters1" title="Open example"> C# </label> <div aria-labelledby="tab-json_tutorial-stepupdate_filters1" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_json_tutorial-stepupdate_filters1" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.RedisStackCommands</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">Json_tutorial</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\"Hyperion\""</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">JsonType</span><span class="p">[]</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Type</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res3</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; STRING</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_get' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">StrLen</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res4</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 8</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">StrAppend</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">" (Enduro bikes)"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res5</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 23</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'str' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">0</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1.5</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2.5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="p">-</span><span class="m">0.75</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1.75</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'num' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="k">new</span> <span class="kt">object?</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="k">new</span> <span class="p">{</span> <span class="n">crashes</span> <span class="p">=</span> <span class="m">0</span> <span class="p">},</span> <span class="k">null</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$[1].crashes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res13</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [0]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Del</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$.[-1]"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res14</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res15</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="k">new</span> <span class="kt">object</span><span class="p">[]</span> <span class="p">{</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res16</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrAppend</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res17</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res18</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrInsert</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res19</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res20</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem","Prickett","Royce","Castilla"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrTrim</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res21</span><span class="p">));</span> <span class="c1">// 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res22</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span><span class="p">[]</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrPop</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="p">(</span><span class="kt">object</span><span class="p">[])</span><span class="n">res23</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "Prickett"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span><span class="p">[]</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrPop</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="p">(</span><span class="kt">object</span><span class="p">[])</span><span class="n">res24</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; &lt;Empty string&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="p">{</span> <span class="n">model</span> <span class="p">=</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Ergonom"</span><span class="p">,</span> <span class="n">price</span> <span class="p">=</span> <span class="m">4972</span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res25</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ObjLen</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res26</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">IEnumerable</span><span class="p">&lt;</span><span class="n">HashSet</span><span class="p">&lt;</span><span class="kt">string</span><span class="p">&gt;&gt;</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ObjKeys</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res27</span><span class="p">.</span><span class="n">Select</span><span class="p">(</span><span class="n">b</span> <span class="p">=&gt;</span> <span class="s">$"{string.Join("</span><span class="p">,</span> <span class="s">", b.Select(c =&gt; $"</span><span class="p">{</span><span class="n">c</span><span class="p">}</span><span class="s">"))}"</span><span class="p">))</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> <span class="c1">// &gt;&gt;&gt; model, brand, price</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'obj' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">string</span> <span class="n">inventoryJson</span> <span class="p">=</span> <span class="s">@" </span></span></span><span class="line"><span class="cl"><span class="s">{ </span></span></span><span class="line"><span class="cl"><span class="s"> ""inventory"": { </span></span></span><span class="line"><span class="cl"><span class="s"> ""mountain_bikes"": [ </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:1"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Phoebe"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there\u2019s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 1920, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""carbon"", ""weight"": 13.1}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""silver""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:2"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Quaoar"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and tear. All in all it's an impressive package for the price, making it very competitive."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 2072, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""aluminium"", ""weight"": 7.9}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""white""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:3"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Weywot"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 3264, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""alloy"", ""weight"": 13.8} </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s"> ], </span></span></span><span class="line"><span class="cl"><span class="s"> ""commuter_bikes"": [ </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:4"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Salacia"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, this is a bike which doesn\u2019t break the bank and delivers craved performance. It\u2019s for the rider who wants both efficiency and capability."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 1475, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""aluminium"", ""weight"": 16.6}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""silver""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:5"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Mimas"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 3941, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""alloy"", ""weight"": 11.6} </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s"> ] </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s">}"</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">inventoryJson</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res28</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.*"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; {[[{"id":"bike:1","model":"Phoebe", ...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res30</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res32</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res32</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_mtnbikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res33</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res33</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot","Salacia","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_models' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res34</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[0:2].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res34</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get2mtnbikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res35</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res35</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [{"id":"bike:2","model":"Quaoar","description":"Redesigned for the 2020 model year...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter1' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res36</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[?(@.specs.material == 'alloy')].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res36</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Weywot","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res37</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res37</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot","Salacia","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter3' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res38</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res38</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res39</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res39</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res40</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res40</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res41</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res41</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter4' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res42</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..price"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res42</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res43</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="p">-</span><span class="m">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res43</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1820, 1972, 3164, 1375, 3841</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res44</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res44</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1920, 2072, 3264, 1475, 3941</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">bool</span> <span class="n">res45</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="m">1500</span> </span></span><span class="line hl"><span class="cl"> <span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res45</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res46</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..price"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res46</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [1500,2072,3264,1500,3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters1' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res47</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrAppend</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s">"pink"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res47</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 3, 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res48</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[*].colors"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res48</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["black","silver","pink"],["black","white"],["black","silver","pink"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_json_tutorial-stepupdate_filters1')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_json_tutorial-stepupdate_filters1" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/Json_tutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <p> JSONPath queries also work with other JSON commands that accept a path as an argument. For example, you can add a new color option for a set of headphones with <a href="/docs/latest/commands/json.arrappend/"> <code> JSON.ARRAPPEND </code> </a> : </p> <div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="json_tutorial-stepupdate_filters2"> <input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_json_tutorial-stepupdate_filters2" name="json_tutorial-stepupdate_filters2" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_json_tutorial-stepupdate_filters2" title="Open example"> &gt;_ Redis CLI </label> <div aria-labelledby="tab-json_tutorial-stepupdate_filters2" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_json_tutorial-stepupdate_filters2" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">&gt; JSON.ARRAPPEND bikes:inventory '$.inventory.*[?(@.price&lt;2000)].colors' '"pink"' </span></span><span class="line hl"><span class="cl">1) (integer) 3 </span></span><span class="line hl"><span class="cl">2) (integer) 3 </span></span><span class="line hl"><span class="cl">127.0.0.1:6379&gt; JSON.GET bikes:inventory $..[*].colors </span></span><span class="line hl"><span class="cl">"[[\"black\",\"silver\",\"pink\"],[\"black\",\"white\"],[\"black\",\"silver\",\"pink\"]]"</span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_json_tutorial-stepupdate_filters2')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <div class="flex-1 text-xs text-white overflow-ellipsis"> Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis. </div> <div class="text-right"> <a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight"> <svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg"> <path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"> </path> <path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"> </path> <path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"> </path> <path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"> </path> <path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"> </path> <path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"> </path> <path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"> </path> <path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"> </path> </svg> <span> Get Redis Insight </span> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="python" id="Python_json_tutorial-stepupdate_filters2" name="json_tutorial-stepupdate_filters2" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_json_tutorial-stepupdate_filters2" title="Open example"> Python </label> <div aria-labelledby="tab-json_tutorial-stepupdate_filters2" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_json_tutorial-stepupdate_filters2" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">""" </span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for JSON doc pages: </span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/json/ </span></span></span><span class="line"><span class="cl"><span class="s2">"""</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s1">'"Hyperion"'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Hyperion"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['string']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">strlen</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [10]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">strappend</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s1">'" (Enduro bikes)"'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; 27</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Hyperion"" (Enduro bikes)"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [2.5]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1.75]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"Deimos"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"crashes"</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span> <span class="kc">None</span><span class="p">])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res11</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res12</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['["Deimos", { "crashes": 0 }, null]']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$[1].crashes"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res13</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['0']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$.[-1]"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Deimos', {'crashes': 0}]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[])</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrappend</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s2">"Norem"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res18</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Norem']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrinsert</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">,</span> <span class="s2">"Royce"</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [4]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Norem', 'Prickett', 'Royce', 'Castilla']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrtrim</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res21</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res22</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res22</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Prickett']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res23</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrpop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res23</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['"Prickett"']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res24</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrpop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res24</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [None]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res25</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Deimos"</span><span class="p">,</span> <span class="s2">"brand"</span><span class="p">:</span> <span class="s2">"Ergonom"</span><span class="p">,</span> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">4972</span><span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res25</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res26</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">objlen</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res26</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [3]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res27</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">objkeys</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res27</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['model', 'brand', 'price']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">inventory_json</span> <span class="o">=</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"inventory"</span><span class="p">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mountain_bikes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This is a mid-travel trail slayer that is a fantastic "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"gives plenty of gear range to tackle hills and there</span><span class="se">\u2019</span><span class="s2">s room for "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mudguards and a rack too. This is the bike for the rider who wants "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"carbon"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"Redesigned for the 2020 model year, this bike "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"impressed our testers and is the best all-around trail bike we've "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"ever tested. The Shimano gear system effectively does away with an "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"external cassette, so is super low maintenance in terms of wear "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"and tear. All in all it's an impressive package for the price, "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"white"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This bike gives kids aged six years and older "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"a durable and uberlight mountain bike for their first experience "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"on tracks and easy cruising through forests and fields. A set of "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"ability. If you're after a budget option, this is one of the best "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"alloy"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="s2">"commuter_bikes"</span><span class="p">:</span> <span class="p">[</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"This bike is a great option for anyone who just "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"wants a bike to get about on With a slick-shifting Claris gears "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"from Shimano</span><span class="se">\u2019</span><span class="s2">s, this is a bike which doesn</span><span class="se">\u2019</span><span class="s2">t break the "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bank and delivers craved performance. It</span><span class="se">\u2019</span><span class="s2">s for the rider "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="p">:</span> <span class="s2">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="p">:</span> <span class="s2">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="p">:</span> <span class="s2">"A real joy to ride, this bike got very high "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"scores in last years Bike of the year report. The carefully "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"Vittoria Zaffiro tires give balance and grip.It includes "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"conveniently placed thumb throttle. Put it all together and you "</span> </span></span><span class="line"><span class="cl"> <span class="s2">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="p">:</span> <span class="p">{</span><span class="s2">"material"</span><span class="p">:</span> <span class="s2">"alloy"</span><span class="p">,</span> <span class="s2">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="n">inventory_json</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; [[{'id': 'bike:1', 'model': 'Phoebe',</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; 'description': 'This is a mid-travel trail slayer...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[*].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s1">'$.inventory["mountain_bikes"][*].model'</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..mountain_bikes[*].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar', 'Weywot', 'Salacia', 'Mimas']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..mountain_bikes[0:2].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['Phoebe', 'Quaoar']]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="c1"># &gt;&gt;&gt; [{'id': 'bike:2', 'model': 'Quaoar',</span> </span></span><span class="line"><span class="cl"><span class="c1"># 'description': "Redesigned for the 2020 model year...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[?(@.specs.material == 'alloy')].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Weywot', 'Mimas']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res10</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res10</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Quaoar', 'Weywot', 'Salacia', 'Mimas']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res11</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res12</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res13</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> <span class="s2">"(?i)al"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res14</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res14</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; ['Quaoar', 'Weywot']</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res15</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res15</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1920, 2072, 3264, 1475, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res16</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res16</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1820, 1972, 3164, 1375, 3841]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res17</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">numincrby</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res17</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1920, 2072, 3264, 1475, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="n">res18</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> <span class="mi">1500</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="n">res19</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">)</span> </span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res19</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [1500, 2072, 3264, 1500, 3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res20</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">arrappend</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s2">"pink"</span> </span></span><span class="line hl"><span class="cl"><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res20</span><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [3, 3]</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"><span class="n">res21</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..[*].colors"</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="n">res21</span> </span></span><span class="line hl"><span class="cl"><span class="p">)</span> <span class="c1"># &gt;&gt;&gt; [['black', 'silver', 'pink'], ['black', 'white'], ['black', 'silver', 'pink']]</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_json_tutorial-stepupdate_filters2')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Python_json_tutorial-stepupdate_filters2" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start"> Python Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_json.py" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_json_tutorial-stepupdate_filters2" name="json_tutorial-stepupdate_filters2" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_json_tutorial-stepupdate_filters2" title="Open example"> Node.js </label> <div aria-labelledby="tab-json_tutorial-stepupdate_filters2" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_json_tutorial-stepupdate_filters2" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">createClient</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span> </span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s1">'"Hyperion"'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// "Hyperion" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">type</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// [ 'string' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">strLen</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// [10] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">strAppend</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s1">'" (Enduro bikes)"'</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// 27 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// ['"Hyperion"" (Enduro bikes)"'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"crashes"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[</span><span class="s2">"Deimos"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"crashes"</span><span class="o">:</span> <span class="mi">0</span> <span class="p">},</span> <span class="kc">null</span><span class="p">]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res11</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res12</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 }, null ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res13</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$[1].crashes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res13</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 }, null ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res14</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">del</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$.[-1]"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res14</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res15</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"newbike"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res15</span><span class="p">);</span> <span class="c1">// [ 'Deimos', { crashes: 0 } ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res16</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">[]);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res16</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res17</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrAppend</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="s2">"Norem"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res17</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res18</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res18</span><span class="p">);</span> <span class="c1">// [ 'Norem' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res19</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrInsert</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"Prickett"</span><span class="p">,</span> <span class="s2">"Royse"</span><span class="p">,</span> <span class="s2">"Castilla"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res19</span><span class="p">);</span> <span class="c1">// [4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res20</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res20</span><span class="p">);</span> <span class="c1">// [ 'Norem', 'Prickett', 'Royse', 'Castilla' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res21</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrTrim</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res21</span><span class="p">);</span> <span class="c1">// [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res22</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res22</span><span class="p">);</span> <span class="c1">// [ 'Prickett' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res23</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrPop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res23</span><span class="p">);</span> <span class="c1">// [ 'Prickett' ] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res24</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrPop</span><span class="p">(</span><span class="s2">"riders"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res24</span><span class="p">);</span> <span class="c1">// [null] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res25</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"brand"</span><span class="o">:</span> <span class="s2">"Ergonom"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">4972</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res25</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res26</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">objLen</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res26</span><span class="p">);</span> <span class="c1">// [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res27</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">objKeys</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res27</span><span class="p">);</span> <span class="c1">// [['model', 'brand', 'price']] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">inventoryJSON</span> <span class="o">=</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"inventory"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"mountain_bikes"</span><span class="o">:</span> <span class="p">[{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there\u2019s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"carbon"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">13.1</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">7.9</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"white"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"alloy"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">13.8</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="s2">"commuter_bikes"</span><span class="o">:</span> <span class="p">[{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, this is a bike which doesn\u2019t break the bank and delivers craved performance. It\u2019s for the rider who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"aluminium"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">16.6</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s2">"colors"</span><span class="o">:</span> <span class="p">[</span><span class="s2">"black"</span><span class="p">,</span> <span class="s2">"silver"</span><span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"id"</span><span class="o">:</span> <span class="s2">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"model"</span><span class="o">:</span> <span class="s2">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">"A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"price"</span><span class="o">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"specs"</span><span class="o">:</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="s2">"material"</span><span class="o">:</span> <span class="s2">"alloy"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s2">"weight"</span><span class="o">:</span> <span class="mf">11.6</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">],</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">};</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res28</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$"</span><span class="p">,</span> <span class="nx">inventoryJSON</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res28</span><span class="p">);</span> <span class="c1">// OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res29</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$.inventory.*"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res29</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="cm">/* </span></span></span><span class="line"><span class="cl"><span class="cm">[ </span></span></span><span class="line"><span class="cl"><span class="cm"> [ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:1', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Phoebe', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there’s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 1920, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:2', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Quaoar', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 2072, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:3', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Weywot', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 3264, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm"> ], </span></span></span><span class="line"><span class="cl"><span class="cm"> [ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:4', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Salacia', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano’s, this is a bike which doesn’t break the bank and delivers craved performance. It’s for the rider who wants both efficiency and capability.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 1475, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object], </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [Array] </span></span></span><span class="line"><span class="cl"><span class="cm"> }, </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:5', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Mimas', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: 'A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price.', </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 3941, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: [Object] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm"> ] </span></span></span><span class="line"><span class="cl"><span class="cm">] </span></span></span><span class="line"><span class="cl"><span class="cm">*/</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res30</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$.inventory.mountain_bikes[*].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res30</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res31</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s1">'$.inventory["mountain_bikes"][*].model'</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res31</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res32</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[*].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res32</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res33</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res33</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar', 'Weywot', 'Salacia', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res34</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[0:2].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res34</span><span class="p">);</span> <span class="c1">// ['Phoebe', 'Quaoar'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res35</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res35</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="cm">/* </span></span></span><span class="line"><span class="cl"><span class="cm">[ </span></span></span><span class="line"><span class="cl"><span class="cm"> { </span></span></span><span class="line"><span class="cl"><span class="cm"> id: 'bike:2', </span></span></span><span class="line"><span class="cl"><span class="cm"> model: 'Quaoar', </span></span></span><span class="line"><span class="cl"><span class="cm"> description: "Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and teaawait client. All in all it's an impressive package for the price, making it very competitive.", </span></span></span><span class="line"><span class="cl"><span class="cm"> price: 2072, </span></span></span><span class="line"><span class="cl"><span class="cm"> specs: { material: 'aluminium', weight: 7.9 }, </span></span></span><span class="line"><span class="cl"><span class="cm"> colors: [ 'black', 'white' ] </span></span></span><span class="line"><span class="cl"><span class="cm"> } </span></span></span><span class="line"><span class="cl"><span class="cm">] </span></span></span><span class="line"><span class="cl"><span class="cm">*/</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1">// names of bikes made from an alloy </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res36</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[?(@.specs.material == 'alloy')].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res36</span><span class="p">);</span> <span class="c1">// ['Weywot', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[?(@.specs.material =~ '(?i)al')].model"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37</span><span class="p">);</span> <span class="c1">// ['Quaoar', 'Weywot', 'Salacia', 'Mimas'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37a</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[0].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37b</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[1].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37c</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[2].regex_pat'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'(?i)al'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res37d</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res37d</span><span class="p">);</span> <span class="c1">// ['Quaoar', 'Weywot'] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res38</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..price"</span> </span></span><span class="line"><span class="cl"><span class="p">});</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res38</span><span class="p">);</span> <span class="c1">// [1920, 2072, 3264, 1475, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res39</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res39</span><span class="p">);</span> <span class="c1">// [1820, 1972, 3164, 1375, 3841] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">numIncrBy</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40</span><span class="p">);</span> <span class="c1">// [1920, 2072, 3264, 1475, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res40a</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$.inventory.*[?(@.price&lt;2000)].price'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mi">1500</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="c1">// Get all prices from the inventory </span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res40b</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s1">'bikes:inventory'</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s1">'$..price'</span> </span></span><span class="line"><span class="cl"><span class="p">);</span> </span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res40b</span><span class="p">);</span> <span class="c1">// [1500, 2072, 3264, 1500, 3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res41</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">arrAppend</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="s2">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s2">"pink"</span> </span></span><span class="line hl"><span class="cl"><span class="p">);</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res41</span><span class="p">);</span> <span class="c1">// [3, 3] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res42</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">json</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bikes:inventory"</span><span class="p">,</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nx">path</span><span class="o">:</span> <span class="s2">"$..[*].colors"</span> </span></span><span class="line hl"><span class="cl"><span class="p">});</span> </span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res42</span><span class="p">);</span> <span class="c1">// [['black', 'silver', 'pink'], ['black', 'white'], ['black', 'silver', 'pink']] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_json_tutorial-stepupdate_filters2')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Nodejs_json_tutorial-stepupdate_filters2" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start"> Node.js Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-json.js" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="java" id="Java_json_tutorial-stepupdate_filters2" name="json_tutorial-stepupdate_filters2" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_json_tutorial-stepupdate_filters2" title="Open example"> Java </label> <div aria-labelledby="tab-json_tutorial-stepupdate_filters2" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_json_tutorial-stepupdate_filters2" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.json.Path2</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.json.JSONArray</span><span class="o">;</span> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.json.JSONObject</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">JsonExample</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span> </span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">"\"Hyperion\""</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Class</span><span class="o">&lt;?&gt;&gt;</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonType</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [class java.lang.String] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_get' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonStrLen</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [8] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonStrAppend</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">" (Enduro bikes)"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [23] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'str' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">0</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res9</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mf">1.5</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res9</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res10</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="o">-</span><span class="mf">0.75</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res10</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'num' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res11</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">JSONArray</span><span class="o">()</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"Deimos"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="k">new</span> <span class="n">JSONObject</span><span class="o">().</span><span class="na">put</span><span class="o">(</span><span class="s">"crashes"</span><span class="o">,</span> <span class="mi">0</span><span class="o">))</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">((</span><span class="n">Object</span><span class="o">)</span> <span class="kc">null</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res11</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res12</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res12</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res13</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$[1].crashes"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res13</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [0] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res14</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonDel</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.[-1]"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res14</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res15</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"newbike"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res15</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res16</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="k">new</span> <span class="n">JSONArray</span><span class="o">());</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res16</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res17</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrAppendWithEscape</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="s">"Norem"</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res17</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res18</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res18</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res19</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrInsertWithEscape</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">,</span> <span class="s">"Prickett"</span><span class="o">,</span> <span class="s">"Royce"</span><span class="o">,</span> <span class="s">"Castilla"</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res19</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [4] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res20</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res20</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["Norem","Prickett","Royce","Castilla"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res21</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrTrim</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="mi">1</span><span class="o">,</span> <span class="mi">1</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res21</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res22</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res22</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res23</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrPop</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res23</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [Prickett] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res24</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrPop</span><span class="o">(</span><span class="s">"riders"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res24</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [null] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res25</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">JSONObject</span><span class="o">()</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"model"</span><span class="o">,</span> <span class="s">"Deimos"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"brand"</span><span class="o">,</span> <span class="s">"Ergonom"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"price"</span><span class="o">,</span> <span class="mi">4972</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res25</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res26</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonObjLen</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res26</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;&gt;</span> <span class="n">res27</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonObjKeys</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res27</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [[price, model, brand]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'obj' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">inventory_json</span> <span class="o">=</span> <span class="s">"{"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"inventory\": {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"mountain_bikes\": ["</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:1\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Phoebe\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This is a mid-travel trail slayer that is a "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for mudguards "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and a rack too. This is the bike for the rider who wants trail manners with "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"low fuss ownership.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1920,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"carbon\", \"weight\": 13.1},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"silver\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:2\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Quaoar\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"Redesigned for the 2020 model year, this "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"bike impressed our testers and is the best all-around trail bike we've ever "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"tested. The Shimano gear system effectively does away with an external cassette, "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"so is super low maintenance in terms of wear and tear. All in all it's an "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"impressive package for the price, making it very competitive.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 2072,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"aluminium\", \"weight\": 7.9},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"white\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:3\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Weywot\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This bike gives kids aged six years and older "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"a durable and uberlight mountain bike for their first experience on tracks and easy "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"provide ample stopping ability. If you're after a budget option, this is one of the "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"best bikes you could get.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3264,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"alloy\", \"weight\": 13.8}"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" ],"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"commuter_bikes\": ["</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:4\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Salacia\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This bike is a great option for anyone who just "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"this is a bike which doesn\u2019t break the bank and delivers craved performance. "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"It\u2019s for the rider who wants both efficiency and capability.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1475,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"aluminium\", \"weight\": 16.6},"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"colors\": [\"black\", \"silver\"]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" },"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" {"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"id\": \"bike:5\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Mimas\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"A real joy to ride, this bike got very high scores "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"in last years Bike of the year report. The carefully crafted 50-34 tooth chainset "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"throttle. Put it all together and you get a bike that helps redefine what can be "</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"done for this price.\","</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3941,"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"specs\": {\"material\": \"alloy\", \"weight\": 11.6}"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" ]"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" }"</span> </span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"}"</span><span class="o">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res28</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$"</span><span class="o">),</span> <span class="n">inventory_json</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res28</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res29</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res29</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [[{"specs":{"material":"carbon","weight":13.1},"price":1920, ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res30</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res30</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res31</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res31</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res32</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[*].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res32</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_mtnbikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res33</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..model"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res33</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot","Salacia","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_models' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res34</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[0:2].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res34</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get2mtnbikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res35</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res35</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [{"specs":{"material":"aluminium","weight":7.9},"price":2072,... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter1' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res36</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[?(@.specs.material == 'alloy')].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res36</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Weywot","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res37</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res37</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot","Salacia","Mimas"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter3' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="o">),</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res38</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="o">)</span> </span></span><span class="line"><span class="cl"> <span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res38</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter4' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res39</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res39</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res40</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">),</span> <span class="o">-</span><span class="mi">100</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res40</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1820,1972,3164,1375,3841] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res41</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonNumIncrBy</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">),</span> <span class="mi">100</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res41</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_bikes' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonSet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="o">),</span> <span class="mi">1500</span><span class="o">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Object</span> <span class="n">res42</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..price"</span><span class="o">));</span> </span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res42</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [1500,2072,3264,1500,3941] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters1' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">List</span><span class="o">&lt;</span><span class="n">Long</span><span class="o">&gt;</span> <span class="n">res43</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonArrAppendWithEscape</span><span class="o">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="o">),</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"\"pink\""</span> </span></span><span class="line hl"><span class="cl"> <span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res43</span><span class="o">);</span> <span class="c1">// &gt;&gt;&gt; [3, 3] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="n">Object</span> <span class="n">res44</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">jsonGet</span><span class="o">(</span><span class="s">"bikes:inventory"</span><span class="o">,</span> <span class="k">new</span> <span class="n">Path2</span><span class="o">(</span><span class="s">"$..[*].colors"</span><span class="o">));</span> </span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res44</span><span class="o">);</span> </span></span><span class="line hl"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["black","silver","\"pink\""],["black","white"],["black","silver","\"pink\""]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters2' step. </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">close</span><span class="o">();</span> </span></span><span class="line"><span class="cl"> <span class="o">}</span> </span></span><span class="line"><span class="cl"><span class="o">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_json_tutorial-stepupdate_filters2')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Java_json_tutorial-stepupdate_filters2" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start"> Java Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/JsonExample.java" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="go" id="Go_json_tutorial-stepupdate_filters2" name="json_tutorial-stepupdate_filters2" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_json_tutorial-stepupdate_filters2" title="Open example"> Go </label> <div aria-labelledby="tab-json_tutorial-stepupdate_filters2" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_json_tutorial-stepupdate_filters2" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"context"</span> </span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span> </span></span><span class="line"><span class="cl"><span class="p">)</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_setget</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Hyperion\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONType</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [[string]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_str</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Hyperion\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONStrLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res4</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 8 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONStrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\" (Enduro bikes)\""</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res5</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 23 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_num</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [2.5] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.75</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1.75] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_arr</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"crashes"</span><span class="p">:</span> <span class="mi">0</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kc">nil</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$[1].crashes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [0] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONDel</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$.[-1]"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; 1 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_arr2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{}).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\"Norem\""</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrInsert</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"Prickett\""</span><span class="p">,</span> <span class="s">"\"Royce\""</span><span class="p">,</span> <span class="s">"\"Castilla\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// [3] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Norem", "Prickett", "Royce", "Castilla"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">rangeStop</span> <span class="o">:=</span> <span class="mi">1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrTrimWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONArrTrimArgs</span><span class="p">{</span><span class="nx">Start</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">Stop</span><span class="p">:</span> <span class="o">&amp;</span><span class="nx">rangeStop</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res22</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res22</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res23</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res23</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res24</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrPop</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res24</span><span class="p">)</span> <span class="c1">// [] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_obj</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res25</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Deimos"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"brand"</span><span class="p">:</span> <span class="s">"Ergonom"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">4972</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res25</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res26</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONObjLen</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="o">*</span><span class="nx">res26</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="c1">// &gt;&gt;&gt; 3 </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res27</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONObjKeys</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res27</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [brand model price] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">var</span> <span class="nx">inventory_json</span> <span class="p">=</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"inventory"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"mountain_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This is a mid-travel trail slayer that is a fantastic "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"mudguards and a rack too. This is the bike for the rider who wants "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"carbon"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"Redesigned for the 2020 model year, this bike "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"impressed our testers and is the best all-around trail bike we've "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ever tested. The Shimano gear system effectively does away with an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"external cassette, so is super low maintenance in terms of wear "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"and tear. All in all it's an impressive package for the price, "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"white"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike gives kids aged six years and older "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a durable and uberlight mountain bike for their first experience "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"on tracks and easy cruising through forests and fields. A set of "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ability. If you're after a budget option, this is one of the best "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"commuter_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike is a great option for anyone who just "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"from Shimano\u2019s, this is a bike which doesn\u2019t break the "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bank and delivers craved performance. It\u2019s for the rider "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"A real joy to ride, this bike got very high "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"scores in last years Bike of the year report. The carefully "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"Vittoria Zaffiro tires give balance and grip.It includes "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"conveniently placed thumb throttle. Put it all together and you "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_setbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kd">var</span> <span class="nx">inventory_json</span> <span class="p">=</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"inventory"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"mountain_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:1"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Phoebe"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This is a mid-travel trail slayer that is a fantastic "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"daily driver or one bike quiver. The Shimano Claris 8-speed groupset "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"gives plenty of gear range to tackle hills and there\u2019s room for "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"mudguards and a rack too. This is the bike for the rider who wants "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"trail manners with low fuss ownership."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1920</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"carbon"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:2"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Quaoar"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"Redesigned for the 2020 model year, this bike "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"impressed our testers and is the best all-around trail bike we've "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ever tested. The Shimano gear system effectively does away with an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"external cassette, so is super low maintenance in terms of wear "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"and tear. All in all it's an impressive package for the price, "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"making it very competitive."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">2072</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">7.9</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"white"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:3"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Weywot"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike gives kids aged six years and older "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a durable and uberlight mountain bike for their first experience "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"on tracks and easy cruising through forests and fields. A set of "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"powerful Shimano hydraulic disc brakes provide ample stopping "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"ability. If you're after a budget option, this is one of the best "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes you could get."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3264</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">13.8</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"commuter_bikes"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:4"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Salacia"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"This bike is a great option for anyone who just "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"wants a bike to get about on With a slick-shifting Claris gears "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"from Shimano\u2019s, this is a bike which doesn\u2019t break the "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"bank and delivers craved performance. It\u2019s for the rider "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"who wants both efficiency and capability."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">1475</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"aluminium"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">16.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"colors"</span><span class="p">:</span> <span class="p">[]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"black"</span><span class="p">,</span> <span class="s">"silver"</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span> </span></span><span class="line"><span class="cl"> <span class="s">"id"</span><span class="p">:</span> <span class="s">"bike:5"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"model"</span><span class="p">:</span> <span class="s">"Mimas"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"description"</span><span class="p">:</span> <span class="s">"A real joy to ride, this bike got very high "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"scores in last years Bike of the year report. The carefully "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"crafted 50-34 tooth chainset and 11-32 tooth cassette give an "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"easy-on-the-legs bottom gear for climbing, and the high-quality "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"Vittoria Zaffiro tires give balance and grip.It includes "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"a low-step frame , our memory foam seat, bump-resistant shocks and "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"conveniently placed thumb throttle. Put it all together and you "</span> <span class="o">+</span> </span></span><span class="line"><span class="cl"> <span class="s">"get a bike that helps redefine what can be done for this price."</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"price"</span><span class="p">:</span> <span class="mi">3941</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"specs"</span><span class="p">:</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span><span class="s">"material"</span><span class="p">:</span> <span class="s">"alloy"</span><span class="p">,</span> <span class="s">"weight"</span><span class="p">:</span> <span class="mf">11.6</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGetWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONGetArgs</span><span class="p">{</span><span class="nx">Indent</span><span class="p">:</span> <span class="s">" "</span><span class="p">,</span> <span class="nx">Newline</span><span class="p">:</span> <span class="s">"\n"</span><span class="p">,</span> <span class="nx">Space</span><span class="p">:</span> <span class="s">" "</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// { </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "colors": [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "black", </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "silver" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getmtnbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..mountain_bikes[*].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_getmodels</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..model"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Salacia","Mimas","Phoebe","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_get2mtnbikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..mountain_bikes[0:2].model"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGetWithArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">JSONGetArgs</span><span class="p">{</span><span class="nx">Indent</span><span class="p">:</span> <span class="s">" "</span><span class="p">,</span> <span class="nx">Newline</span><span class="p">:</span> <span class="s">"\n"</span><span class="p">,</span> <span class="nx">Space</span><span class="p">:</span> <span class="s">" "</span><span class="p">},</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// { </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "colors": [ </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "black", </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "white" </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ], </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// "description": "Redesigned for the 2020 model year </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// ... </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..[?(@.specs.material == 'alloy')].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Mimas","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter3</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Salacia","Mimas","Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_filter4</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res11</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res11</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res12</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res12</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res13</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res13</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res14</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res14</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatebikes</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res15</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res15</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1475,3941,1920,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res16</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="o">-</span><span class="mi">100</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res16</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1375,3841,1820,1972,3164] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res17</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONNumIncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="mi">100</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res17</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1475,3941,1920,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatefilters1</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">res18</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="mi">1500</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res18</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; OK </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"> <span class="nx">res19</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res19</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [1500,3941,1500,2072,3264] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_updatefilters2</span><span class="p">()</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&amp;</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB </span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="nx">_</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="nx">inventory_json</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">res20</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONArrAppend</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"\"pink\""</span><span class="p">,</span> </span></span><span class="line hl"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res20</span><span class="p">)</span> <span class="c1">// &gt;&gt;&gt; [3 3] </span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> </span></span><span class="line hl"><span class="cl"> <span class="nx">res21</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">JSONGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..[*].colors"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span> </span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="p">}</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res21</span><span class="p">)</span> </span></span><span class="line hl"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [["black","silver","pink"],["black","silver","pink"],["black","white"]] </span></span></span><span class="line"><span class="cl"><span class="c1"></span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_json_tutorial-stepupdate_filters2')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Go_json_tutorial-stepupdate_filters2" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start"> Go Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/json_tutorial_test.go" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> <input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_json_tutorial-stepupdate_filters2" name="json_tutorial-stepupdate_filters2" tabindex="1" type="radio"/> <label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_json_tutorial-stepupdate_filters2" title="Open example"> C# </label> <div aria-labelledby="tab-json_tutorial-stepupdate_filters2" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_json_tutorial-stepupdate_filters2" role="tabpanel" tabindex="0"> <div class="highlight"> <pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.RedisStackCommands</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span> </span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">Json_tutorial</span> </span></span><span class="line"><span class="cl"><span class="p">{</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span> </span></span><span class="line"><span class="cl"> <span class="p">{</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"\"Hyperion\""</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">JsonType</span><span class="p">[]</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Type</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res3</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; STRING</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_get' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">StrLen</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">Write</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res4</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 8</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">StrAppend</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="s">" (Enduro bikes)"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res5</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 23</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Hyperion (Enduro bikes)"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'str' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">0</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res9</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1.5</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 2.5</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res10</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"crashes"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="p">-</span><span class="m">0.75</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res9</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1.75</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'num' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res11</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="k">new</span> <span class="kt">object?</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="k">new</span> <span class="p">{</span> <span class="n">crashes</span> <span class="p">=</span> <span class="m">0</span> <span class="p">},</span> <span class="k">null</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res11</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res12</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res12</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0},null]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res13</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$[1].crashes"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res13</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [0]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res14</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Del</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="s">"$.[-1]"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res14</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res15</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"newbike"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res15</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Deimos",{"crashes":0}]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res16</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="k">new</span> <span class="kt">object</span><span class="p">[]</span> <span class="p">{</span> <span class="p">});</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res16</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res17</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrAppend</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="s">"Norem"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res17</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res18</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res18</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res19</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrInsert</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="s">"Prickett"</span><span class="p">,</span> <span class="s">"Royce"</span><span class="p">,</span> <span class="s">"Castilla"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res19</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 4</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res20</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res20</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Norem","Prickett","Royce","Castilla"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res21</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrTrim</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="m">1</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res21</span><span class="p">));</span> <span class="c1">// 1</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res22</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res22</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["Prickett"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span><span class="p">[]</span> <span class="n">res23</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrPop</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="p">(</span><span class="kt">object</span><span class="p">[])</span><span class="n">res23</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; "Prickett"</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span><span class="p">[]</span> <span class="n">res24</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrPop</span><span class="p">(</span><span class="s">"riders"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="p">(</span><span class="kt">object</span><span class="p">[])</span><span class="n">res24</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; &lt;Empty string&gt;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'arr2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res25</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="p">{</span> <span class="n">model</span> <span class="p">=</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Ergonom"</span><span class="p">,</span> <span class="n">price</span> <span class="p">=</span> <span class="m">4972</span> <span class="p">}</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res25</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res26</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ObjLen</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res26</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 3</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">IEnumerable</span><span class="p">&lt;</span><span class="n">HashSet</span><span class="p">&lt;</span><span class="kt">string</span><span class="p">&gt;&gt;</span> <span class="n">res27</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ObjKeys</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res27</span><span class="p">.</span><span class="n">Select</span><span class="p">(</span><span class="n">b</span> <span class="p">=&gt;</span> <span class="s">$"{string.Join("</span><span class="p">,</span> <span class="s">", b.Select(c =&gt; $"</span><span class="p">{</span><span class="n">c</span><span class="p">}</span><span class="s">"))}"</span><span class="p">))</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> <span class="c1">// &gt;&gt;&gt; model, brand, price</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'obj' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">string</span> <span class="n">inventoryJson</span> <span class="p">=</span> <span class="s">@" </span></span></span><span class="line"><span class="cl"><span class="s">{ </span></span></span><span class="line"><span class="cl"><span class="s"> ""inventory"": { </span></span></span><span class="line"><span class="cl"><span class="s"> ""mountain_bikes"": [ </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:1"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Phoebe"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This is a mid-travel trail slayer that is a fantastic daily driver or one bike quiver. The Shimano Claris 8-speed groupset gives plenty of gear range to tackle hills and there\u2019s room for mudguards and a rack too. This is the bike for the rider who wants trail manners with low fuss ownership."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 1920, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""carbon"", ""weight"": 13.1}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""silver""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:2"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Quaoar"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""Redesigned for the 2020 model year, this bike impressed our testers and is the best all-around trail bike we've ever tested. The Shimano gear system effectively does away with an external cassette, so is super low maintenance in terms of wear and tear. All in all it's an impressive package for the price, making it very competitive."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 2072, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""aluminium"", ""weight"": 7.9}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""white""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:3"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Weywot"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This bike gives kids aged six years and older a durable and uberlight mountain bike for their first experience on tracks and easy cruising through forests and fields. A set of powerful Shimano hydraulic disc brakes provide ample stopping ability. If you're after a budget option, this is one of the best bikes you could get."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 3264, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""alloy"", ""weight"": 13.8} </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s"> ], </span></span></span><span class="line"><span class="cl"><span class="s"> ""commuter_bikes"": [ </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:4"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Salacia"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""This bike is a great option for anyone who just wants a bike to get about on With a slick-shifting Claris gears from Shimano\u2019s, this is a bike which doesn\u2019t break the bank and delivers craved performance. It\u2019s for the rider who wants both efficiency and capability."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 1475, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""aluminium"", ""weight"": 16.6}, </span></span></span><span class="line"><span class="cl"><span class="s"> ""colors"": [""black"", ""silver""] </span></span></span><span class="line"><span class="cl"><span class="s"> }, </span></span></span><span class="line"><span class="cl"><span class="s"> { </span></span></span><span class="line"><span class="cl"><span class="s"> ""id"": ""bike:5"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""model"": ""Mimas"", </span></span></span><span class="line"><span class="cl"><span class="s"> ""description"": ""A real joy to ride, this bike got very high scores in last years Bike of the year report. The carefully crafted 50-34 tooth chainset and 11-32 tooth cassette give an easy-on-the-legs bottom gear for climbing, and the high-quality Vittoria Zaffiro tires give balance and grip.It includes a low-step frame , our memory foam seat, bump-resistant shocks and conveniently placed thumb throttle. Put it all together and you get a bike that helps redefine what can be done for this price."", </span></span></span><span class="line"><span class="cl"><span class="s"> ""price"": 3941, </span></span></span><span class="line"><span class="cl"><span class="s"> ""specs"": {""material"": ""alloy"", ""weight"": 11.6} </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s"> ] </span></span></span><span class="line"><span class="cl"><span class="s"> } </span></span></span><span class="line"><span class="cl"><span class="s">}"</span><span class="p">;</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res28</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">inventoryJson</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res28</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'set_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res29</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.*"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res29</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; {[[{"id":"bike:1","model":"Phoebe", ...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res30</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.mountain_bikes[*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res30</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res31</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory[\"mountain_bikes\"][*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res31</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res32</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[*].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res32</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_mtnbikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res33</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res33</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar","Weywot","Salacia","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get_models' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res34</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[0:2].model"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res34</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Phoebe","Quaoar"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'get2mtnbikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res35</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..mountain_bikes[?(@.price &lt; 3000 &amp;&amp; @.specs.weight &lt; 10)]"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res35</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="c1">// &gt;&gt;&gt; [{"id":"bike:2","model":"Quaoar","description":"Redesigned for the 2020 model year...</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter1' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res36</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[?(@.specs.material == 'alloy')].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res36</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Weywot","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res37</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[?(@.specs.material =~ '(?i)al')].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res37</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot","Salacia","Mimas"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter3' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res38</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[0].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res38</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res39</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[1].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res39</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res40</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.mountain_bikes[2].regex_pat"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"\"(?i)al\""</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res40</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res41</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="n">path</span><span class="p">:</span> <span class="s">"$.inventory.mountain_bikes[?(@.specs.material =~ @.regex_pat)].model"</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res41</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; ["Quaoar","Weywot"]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'filter4' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res42</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..price"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res42</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [1920,2072,3264,1475,3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res43</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="p">-</span><span class="m">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res43</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1820, 1972, 3164, 1375, 3841</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">double?</span><span class="p">[]</span> <span class="n">res44</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">NumIncrby</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$..price"</span><span class="p">,</span> <span class="m">100</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res44</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 1920, 2072, 3264, 1475, 3941</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_bikes' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res45</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Set</span><span class="p">(</span> </span></span><span class="line"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="s">"$.inventory.*[?(@.price&lt;2000)].price"</span><span class="p">,</span> </span></span><span class="line"><span class="cl"> <span class="m">1500</span> </span></span><span class="line"><span class="cl"> <span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res45</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; True</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res46</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..price"</span><span class="p">);</span> </span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res46</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [1500,2072,3264,1500,3941]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters1' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="kt">long?</span><span class="p">[]</span> <span class="n">res47</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">ArrAppend</span><span class="p">(</span> </span></span><span class="line hl"><span class="cl"> <span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="s">"$.inventory.*[?(@.price&lt;2000)].colors"</span><span class="p">,</span> <span class="s">"pink"</span> </span></span><span class="line hl"><span class="cl"> <span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">res47</span><span class="p">));</span> <span class="c1">// &gt;&gt;&gt; 3, 3</span> </span></span><span class="line hl"><span class="cl"> </span></span><span class="line hl"><span class="cl"> <span class="n">RedisResult</span> <span class="n">res48</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">JSON</span><span class="p">().</span><span class="n">Get</span><span class="p">(</span><span class="s">"bikes:inventory"</span><span class="p">,</span> <span class="n">path</span><span class="p">:</span> <span class="s">"$..[*].colors"</span><span class="p">);</span> </span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res48</span><span class="p">);</span> <span class="c1">// &gt;&gt;&gt; [["black","silver","pink"],["black","white"],["black","silver","pink"]]</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'update_filters2' step.</span> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> </span></span><span class="line"><span class="cl"> <span class="p">}</span> </span></span><span class="line"><span class="cl"><span class="p">}</span> </span></span><span class="line"><span class="cl"> </span></span></code></pre> </div> <button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_json_tutorial-stepupdate_filters2')" tabindex="1" title="Copy to clipboard"> <svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z"> </path> </svg> <div class="tooltip relative inline-block"> <span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4"> Copied! </span> </div> </button> <button aria-controls="panel_Csharp_json_tutorial-stepupdate_filters2" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility"> <svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z"> </path> </svg> <svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"> <path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z"> </path> </svg> </button> <div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible"> <a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start"> C# Quick-Start </a> <div class="w-1/2"> </div> <div class="flex-1 text-right"> <a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/Json_tutorial.cs" tabindex="1" title="Improve this code example"> <svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg"> <path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd"> </path> </svg> </a> </div> </div> </div> </div> <h2 id="legacy-path-syntax"> Legacy path syntax </h2> <p> RedisJSON v1 had the following path implementation. JSON v2 still supports this legacy path in addition to JSONPath. </p> <p> Paths always begin at the root of a Redis JSON value. The root is denoted by a period character ( <code> . </code> ). For paths that reference the root's children, it is optional to prefix the path with the root. </p> <p> Redis JSON supports both dot notation and bracket notation for object key access. The following paths refer to <em> headphones </em> , which is a child of <em> inventory </em> under the root: </p> <ul> <li> <code> .inventory.headphones </code> </li> <li> <code> inventory["headphones"] </code> </li> <li> <code> ['inventory']["headphones"] </code> </li> </ul> <p> To access an array element, enclose its index within a pair of square brackets. The index is 0-based, with 0 being the first element of the array, 1 being the next element, and so on. You can use negative offsets to access elements starting from the end of the array. For example, -1 is the last element in the array, -2 is the second to last element, and so on. </p> <h3 id="json-key-names-and-path-compatibility"> JSON key names and path compatibility </h3> <p> By definition, a JSON key can be any valid JSON string. Paths, on the other hand, are traditionally based on JavaScript's (and Java's) variable naming conventions. </p> <p> Although JSON can store objects that contain arbitrary key names, you can only use a legacy path to access these keys if they conform to these naming syntax rules: </p> <ol> <li> Names must begin with a letter, a dollar sign ( <code> $ </code> ), or an underscore ( <code> _ </code> ) character </li> <li> Names can contain letters, digits, dollar signs, and underscores </li> <li> Names are case-sensitive </li> </ol> <h2 id="time-complexity-of-path-evaluation"> Time complexity of path evaluation </h2> <p> The time complexity of searching (navigating to) an element in the path is calculated from: </p> <ol> <li> Child level - every level along the path adds an additional search </li> <li> Key search - O(N) <sup> † </sup> , where N is the number of keys in the parent object </li> <li> Array search - O(1) </li> </ol> <p> This means that the overall time complexity of searching a path is <em> O(N*M) </em> , where N is the depth and M is the number of parent object keys. </p> <p> <sup> † </sup> While this is acceptable for objects where N is small, access can be optimized for larger objects. </p> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/data-types/json/path/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/7.4/references/cli-utilities/rladmin/placement/.html
<section class="prose w-full py-12 max-w-none"> <h1> rladmin placement </h1> <p class="text-lg -mt-5 mb-10"> Configures the shard placement policy for a database. </p> <p> Configures the shard placement policy for a specified database. </p> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin placement </span></span><span class="line"><span class="cl"> db <span class="o">{</span> db:&lt;id&gt; <span class="p">|</span> &lt;name&gt; <span class="o">}</span> </span></span><span class="line"><span class="cl"> <span class="o">{</span> dense <span class="p">|</span> sparse <span class="o">}</span> </span></span></code></pre> </div> <h3 id="parameters"> Parameters </h3> <table> <thead> <tr> <th> Parameter </th> <th> Type/Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> db </td> <td> db:&lt;id&gt; <br/> name </td> <td> Configures shard placement for the specified database </td> </tr> <tr> <td> dense </td> <td> </td> <td> Places new shards on the same node as long as it has resources </td> </tr> <tr> <td> sparse </td> <td> </td> <td> Places new shards on the maximum number of available nodes within the cluster </td> </tr> </tbody> </table> <h3 id="returns"> Returns </h3> <p> Returns the new shard placement policy if the policy was changed successfully. Otherwise, it returns an error. </p> <p> Use <a href="/docs/latest/operate/rs/7.4/references/cli-utilities/rladmin/status/#status-databases"> <code> rladmin status databases </code> </a> to verify that the failover completed. </p> <h3 id="example"> Example </h3> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ rladmin status databases </span></span><span class="line"><span class="cl">DATABASES: </span></span><span class="line"><span class="cl">DB:ID NAME TYPE STATUS SHARDS PLACEMENT REPLICATION PERSISTENCE ENDPOINT </span></span><span class="line"><span class="cl">db:5 tr01 redis active <span class="m">1</span> dense enabled aof redis-12000.cluster.local:12000 </span></span><span class="line"><span class="cl">$ rladmin placement db db:5 sparse </span></span><span class="line"><span class="cl">Shards placement policy is now sparse </span></span><span class="line"><span class="cl">$ rladmin status databases </span></span><span class="line"><span class="cl">DATABASES: </span></span><span class="line"><span class="cl">DB:ID NAME TYPE STATUS SHARDS PLACEMENT REPLICATION PERSISTENCE ENDPOINT </span></span><span class="line"><span class="cl">db:5 tr01 redis active <span class="m">1</span> sparse enabled aof redis-12000.cluster.local:12000 </span></span></code></pre> </div> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/references/cli-utilities/rladmin/placement/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rs/references/rest-api/requests/bdbs/actions/backup_reset_status/.html
<section class="prose w-full py-12 max-w-none"> <h1> Backup reset status database action requests </h1> <p class="text-lg -mt-5 mb-10"> Reset database backup status requests </p> <table> <thead> <tr> <th> Method </th> <th> Path </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="#put-bdbs-actions-backup-reset-status"> PUT </a> </td> <td> <code> /v1/bdbs/{uid}/actions/backup_reset_status </code> </td> <td> Reset database backup status </td> </tr> </tbody> </table> <h2 id="put-bdbs-actions-backup-reset-status"> Reset database backup status </h2> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">PUT /v1/bdbs/<span class="o">{</span>int: uid<span class="o">}</span>/actions/backup_reset_status </span></span></code></pre> </div> <p> Resets the database's <code> backup_status </code> to idle if a backup is not in progress and clears the value of the <code> backup_failure_reason </code> field. </p> <h3 id="permissions"> Permissions </h3> <table> <thead> <tr> <th> Permission name </th> <th> Roles </th> </tr> </thead> <tbody> <tr> <td> <a href="/docs/latest/operate/rs/references/rest-api/permissions/#reset_bdb_current_backup_status"> reset_bdb_current_backup_status </a> </td> <td> admin <br/> cluster_member <br/> db_member </td> </tr> </tbody> </table> <h3 id="put-request"> Request </h3> <h4 id="example-http-request"> Example HTTP request </h4> <div class="highlight"> <pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">PUT /bdbs/1/actions/backup_reset_status </span></span></code></pre> </div> <h4 id="headers"> Headers </h4> <table> <thead> <tr> <th> Key </th> <th> Value </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> Host </td> <td> cnm.cluster.fqdn </td> <td> Domain name </td> </tr> <tr> <td> Accept </td> <td> application/json </td> <td> Accepted media type </td> </tr> </tbody> </table> <h4 id="url-parameters"> URL parameters </h4> <table> <thead> <tr> <th> Field </th> <th> Type </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> uid </td> <td> integer </td> <td> The unique ID of the database </td> </tr> </tbody> </table> <h3 id="put-response"> Response </h3> <p> Returns a status code. </p> <h4 id="put-status-codes"> Status codes </h4> <table> <thead> <tr> <th> Code </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1"> 200 OK </a> </td> <td> The request is accepted and is being processed. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5"> 404 Not Found </a> </td> <td> Attempting to perform an action on a nonexistent database. </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.7"> 406Β NotΒ Acceptable </a> </td> <td> Not all the modules loaded to the database support 'backup_restore' capability </td> </tr> <tr> <td> <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.10"> 409 Conflict </a> </td> <td> Database is currently busy with another action. In this context, this is a temporary condition and the request should be reattempted later. </td> </tr> </tbody> </table> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/rest-api/requests/bdbs/actions/backup_reset_status/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/develop/tools/insight/release-notes/v.2.58.0/.html
<section class="prose w-full py-12"> <h1> Redis Insight v2.58.0, October 2024 </h1> <p class="text-lg -mt-5 mb-10"> Redis Insight v2.58 </p> <h2 id="258-october-2024"> 2.58 (October 2024) </h2> <p> This is the General Availability (GA) release of Redis Insight 2.58. </p> <h3 id="highlights"> Highlights </h3> <ul> <li> Added functionality to start, stop, and reset <a href="https://redis.io/data-integration/?utm_source=redisinsight&amp;utm_medium=repository&amp;utm_campaign=release_notes"> Redis Data Integration </a> pipelines directly in the app, simplifying management and enhancing control </li> <li> Introduced support for subscribing to specific Pub/Sub channel - a <a href="https://github.com/RedisInsight/RedisInsight/issues/1671"> highly requested feature </a> </li> <li> Ability to delete previously added CA and Client certificates to keep them updated </li> </ul> <h3 id="details"> Details </h3> <p> <strong> Features and improvements </strong> </p> <ul> <li> <a href="https://github.com/RedisInsight/RedisInsight/pull/3843"> #3843 </a> Redis Insight now supports starting, stopping, and resetting <a href="https://redis.io/data-integration/?utm_source=redisinsight&amp;utm_medium=repository&amp;utm_campaign=release_notes"> Redis Data Integration </a> (RDI) pipelines. Use RDI version 1.2.9 or later to seamlessly stop or resume processing new data. You can also reset an RDI pipeline to take a new snapshot of the data, process it, and continue tracking changes. To get started, navigate to the "Redis Data Integration" tab on the database list page and add or connect to your RDI endpoint. </li> <li> <a href="https://github.com/RedisInsight/RedisInsight/pull/3832"> #3832 </a> Added support for a <a href="https://github.com/RedisInsight/RedisInsight/issues/1671"> highly requested feature </a> to subscribe to specific Pub/Sub channels. On the Pub/Sub page, you can now subscribe to multiple channels or patterns by entering them as a space delimited list. </li> <li> <a href="https://github.com/RedisInsight/RedisInsight/pull/3796"> #3796 </a> Ability to delete previously added CA and Client certificates to keep them up-to-date. </li> </ul> <p> <strong> Bugs </strong> </p> <ul> <li> <a href="https://github.com/RedisInsight/RedisInsight/pull/3840"> #3840 </a> <a href="https://github.com/RedisInsight/RedisInsight/issues/3833"> Saved </a> SNI and SSH connection information for newly added database connections. </li> <li> <a href="https://github.com/RedisInsight/RedisInsight/pull/3828"> #3828 </a> Fixed an issue to <a href="https://github.com/RedisInsight/RedisInsight/issues/3826"> display multiple hash fields </a> when expanding a hash value. </li> </ul> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/tools/insight/release-notes/v.2.58.0/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/search/commands/.html
<section class="prose w-full py-12 max-w-none"> <h1> Search and query commands </h1> <p class="text-lg -mt-5 mb-10"> Lists search and query commands and provides links to the command reference pages. </p> <p> The following table lists search and query commands. See the command links for more information about each command's syntax, arguments, and examples. </p> <table> <thead> <tr> <th style="text-align:left"> Command </th> <th style="text-align:left"> Redis Enterprise Software </th> <th style="text-align:left"> Redis Cloud <br/> Flexible &amp; Annual </th> <th style="text-align:left"> Redis Cloud <br/> Free &amp; Fixed </th> <th style="text-align:left"> Description </th> </tr> </thead> <tbody> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/ft.aggregate"> FT.AGGREGATE </a> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> Runs a search query on an index and groups, sorts, transforms, limits, and/or filters the results. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/ft.aliasadd"> FT.ALIASADD </a> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> Adds an alias to an index. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/ft.aliasdel"> FT.ALIASDEL </a> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> Removes an alias from an index. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/ft.aliasupdate"> FT.ALIASUPDATE </a> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> Adds an alias to an index. If the alias already exists for a different index, it updates the alias to point to the specified index instead. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/ft.alter"> FT.ALTER </a> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> Adds a new field to an index. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/ft.config-get"> FT.CONFIG GET </a> </td> <td style="text-align:left"> <span title="Not supported"> <nobr> ❌ Not supported </nobr> </span> </td> <td style="text-align:left"> <span title="Not supported"> <nobr> ⚠️ Not supported </nobr> </span> <nobr> <sup> <a href="#table-note-2"> 2 </a> </sup> </nobr> </td> <td style="text-align:left"> <span title="Not supported"> <nobr> ❌ Not supported </nobr> </span> </td> <td style="text-align:left"> Displays configuration options. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/ft.config-help"> FT.CONFIG HELP </a> </td> <td style="text-align:left"> <span title="Not supported"> <nobr> ❌ Not supported </nobr> </span> </td> <td style="text-align:left"> <span title="Not supported"> <nobr> ❌ Not supported </nobr> </span> </td> <td style="text-align:left"> <span title="Not supported"> <nobr> ❌ Not supported </nobr> </span> </td> <td style="text-align:left"> Describes configuration options. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/ft.config-set"> FT.CONFIG SET </a> </td> <td style="text-align:left"> <span title="Not supported"> <nobr> ⚠️ Not supported </nobr> </span> <nobr> <sup> <a href="#table-note-1"> 1 </a> </sup> </nobr> </td> <td style="text-align:left"> <span title="Not supported"> <nobr> ⚠️ Not supported </nobr> </span> <nobr> <sup> <a href="#table-note-2"> 2 </a> </sup> </nobr> </td> <td style="text-align:left"> <span title="Not supported"> <nobr> ❌ Not supported </nobr> </span> </td> <td style="text-align:left"> Sets configuration options. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/ft.create"> FT.CREATE </a> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> Creates an index. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/ft.cursor-del"> FT.CURSOR DEL </a> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> Deletes a cursor. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/ft.cursor-read/"> FT.CURSORΒ READ </a> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> Reads the next results from an existing cursor. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/ft.dictadd"> FT.DICTADD </a> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> Adds terms to a dictionary. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/ft.dictdel"> FT.DICTDEL </a> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> Deletes terms from a dictionary. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/ft.dictdump"> FT.DICTDUMP </a> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> Returns all terms in the specified dictionary. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/ft.dropindex"> FT.DROPINDEX </a> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> Deletes an index. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/ft.explain"> FT.EXPLAIN </a> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> Returns the execution plan for a complex query as a string. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/ft.explaincli"> FT.EXPLAINCLI </a> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> Returns the execution plan for a complex query as an <a href="/docs/latest/develop/reference/protocol-spec/#arrays"> array </a> . </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/ft.info"> FT.INFO </a> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> Returns index information and statistics. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/ft._list"> FT._LIST </a> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> Lists all indexes. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/ft.profile"> FT.PROFILE </a> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> Runs <a href="/docs/latest/commands/ft.search"> FT.SEARCH </a> or <a href="/docs/latest/commands/ft.aggregate"> FT.AGGREGATE </a> and reports performance information. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/ft.search"> FT.SEARCH </a> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> Searches an index for a text query and returns matching documents or document IDs. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/ft.spellcheck"> FT.SPELLCHECK </a> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> Suggests spelling corrections for misspelled terms in a query. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/ft.syndump"> FT.SYNDUMP </a> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> Returns a list of synonym terms and their synonym group IDs. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/ft.synupdate"> FT.SYNUPDATE </a> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> Creates or updates a synonym group with additional terms. </td> </tr> <tr> <td style="text-align:left"> <a href="/docs/latest/commands/ft.tagvals"> FT.TAGVALS </a> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> <span title="Supported"> βœ… Supported </span> </td> <td style="text-align:left"> Returns all distinct values indexed in a tag field. </td> </tr> </tbody> </table> <ol> <li> <p> <a name="table-note-1" style="display: block; height: 80px; margin-top: -80px;"> </a> Use <a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/"> <code> rladmin </code> </a> or the <a href="/docs/latest/operate/rs/references/rest-api/"> REST API </a> to change search and query configuration for Redis Enterprise Software. See <a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/search/config/"> search and query configuration compatibility with Redis Enterprise </a> for more information and examples. </p> </li> <li> <p> <a name="table-note-2" style="display: block; height: 80px; margin-top: -80px;"> </a> <a href="https://redis.com/company/support/"> Contact support </a> to view the current configuration values or request configuration changes for Flexible or Annual Redis Cloud subscriptions. </p> </li> </ol> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/search/commands/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/integrate/write-behind/reference/cli/redis-di-list-jobs/.html
<section class="prose w-full py-12 max-w-none"> <h1> redis-di list-jobs </h1> <p class="text-lg -mt-5 mb-10"> Lists transformation engine's jobs </p> <h2 id="usage"> Usage </h2> <pre tabindex="0"><code>Usage: redis-di list-jobs [OPTIONS] </code></pre> <h2 id="options"> Options </h2> <ul> <li> <p> <code> loglevel </code> : </p> <ul> <li> Type: Choice(['DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL']) </li> <li> Default: <code> info </code> </li> <li> Usage: <code> --loglevel -log-level </code> </li> </ul> </li> <li> <p> <code> rdi_host </code> (REQUIRED): </p> <ul> <li> Type: STRING </li> <li> Default: <code> none </code> </li> <li> Usage: <code> --rdi-host </code> </li> </ul> <p> Host/IP of Write-behind Database </p> </li> <li> <p> <code> rdi_port </code> (REQUIRED): </p> <ul> <li> Type: &lt;IntRange 1000&lt;=x&lt;=65535&gt; </li> <li> Default: <code> none </code> </li> <li> Usage: <code> --rdi-port </code> </li> </ul> <p> Port of Write-behind Database </p> </li> <li> <p> <code> rdi_password </code> : </p> <ul> <li> Type: STRING </li> <li> Default: <code> none </code> </li> <li> Usage: <code> --rdi-password </code> </li> </ul> <p> Write-behind Database Password </p> </li> <li> <p> <code> rdi_key </code> : </p> <ul> <li> Type: STRING </li> <li> Default: <code> none </code> </li> <li> Usage: <code> --rdi-key </code> </li> </ul> <p> Private key file to authenticate with </p> </li> <li> <p> <code> rdi_cert </code> : </p> <ul> <li> Type: STRING </li> <li> Default: <code> none </code> </li> <li> Usage: <code> --rdi-cert </code> </li> </ul> <p> Client certificate file to authenticate with </p> </li> <li> <p> <code> rdi_cacert </code> : </p> <ul> <li> Type: STRING </li> <li> Default: <code> none </code> </li> <li> Usage: <code> --rdi-cacert </code> </li> </ul> <p> CA certificate file to verify with </p> </li> <li> <p> <code> rdi_key_password </code> : </p> <ul> <li> Type: STRING </li> <li> Default: <code> none </code> </li> <li> Usage: <code> --rdi-key-password </code> </li> </ul> <p> Password for unlocking an encrypted private key </p> </li> <li> <p> <code> help </code> : </p> <ul> <li> Type: BOOL </li> <li> Default: <code> false </code> </li> <li> Usage: <code> --help </code> </li> </ul> <p> Show this message and exit. </p> </li> </ul> <h2 id="cli-help"> CLI help </h2> <pre tabindex="0"><code>Usage: redis-di list-jobs [OPTIONS] Lists transformation engine's jobs Options: -log-level, --loglevel [DEBUG|INFO|WARN|ERROR|CRITICAL] [default: INFO] --rdi-host TEXT Host/IP of Write-behind Database [required] --rdi-port INTEGER RANGE Port of Write-behind Database [1000&lt;=x&lt;=65535; required] --rdi-password TEXT Write-behind Database Password --rdi-key TEXT Private key file to authenticate with --rdi-cert TEXT Client certificate file to authenticate with --rdi-cacert TEXT CA certificate file to verify with --rdi-key-password TEXT Password for unlocking an encrypted private key --help Show this message and exit. </code></pre> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/integrate/write-behind/reference/cli/redis-di-list-jobs/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/operate/rc/security/vpc-peering/.html
<section class="prose w-full py-12 max-w-none"> <h1> Enable VPC peering </h1> <p class="text-lg -mt-5 mb-10"> VPC peering uses private IP addresses to route traffic between a Redis Cloud VPC and an application VPC. </p> <p> VPC peering uses private IP addresses to allow network connections between two <a href="https://en.wikipedia.org/wiki/Virtual_private_cloud"> virtual private clouds </a> (VPCs). </p> <p> You can connect your VPC in the Redis Cloud subscription to the VPC of your application. This lets your application connect securely to your Redis Cloud database using VPC peering to optimize the performance of your application. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> VPC peering is available only with Redis Cloud Pro. It is not supported for Redis Cloud Essentials. </div> </div> <p> VPC peering configuration requires you to initiate VPC peering on your Redis Cloud subscription and then accept the VPC peering request for the AWS VPC that you want to peer with. </p> <h2 id="aws-vpc-peering"> AWS VPC peering </h2> <p> If you want to peer a Redis Cloud VPC with an AWS VPC, you need to: </p> <ol> <li> <p> <a href="#config-aws-vpc-peering"> Configure and initiate VPC peering </a> for your Redis Cloud subscription. </p> </li> <li> <p> <a href="#approve-aws-vpc-peering"> Approve the VPC peering request </a> . </p> </li> <li> <p> <a href="#update-route-tables"> Update the routes tables </a> . </p> </li> </ol> <h3 id="config-aws-vpc-peering"> Configure VPC peering </h3> <p> To set up VPC peering: </p> <ol> <li> <p> From the <a href="https://cloud.redis.io/"> Redis Cloud console </a> , select the <strong> Subscriptions </strong> menu and then select your subscription from the list. </p> </li> <li> <p> Select <strong> Connectivity &gt; VPC Peering </strong> . </p> </li> <li> <p> Select <strong> Add peering </strong> . </p> </li> <li> <p> Enter <strong> VPC peering </strong> details: </p> <table> <thead> <tr> <th> Setting </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <em> Consumer AWS Account </em> </td> <td> Your AWS account ID (see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/console_account-alias.html#FindingYourAWSId"> Finding your AWS account ID </a> ) </td> </tr> <tr> <td> <em> Consumer region </em> </td> <td> AWS VPC region </td> </tr> <tr> <td> <em> Consumer VPC ID </em> </td> <td> The VPC ID for the application that needs to access your Redis Cloud VPC (see <a href="https://docs.aws.amazon.com/managedservices/latest/userguide/find-vpc.html"> Finding a VPC ID </a> ) </td> </tr> <tr> <td> <em> Consumer VPC CIDRs </em> </td> <td> <a href="https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing"> CIDR-formatted </a> IP addresses for the AWS VPC that needs to access your Redis Cloud VPC; must not overlap with the <em> Redis producer VPC CIDR </em> (see <a href="https://docs.aws.amazon.com/vpc/latest/userguide/working-with-vpcs.html#view-vpc"> View your VPCs </a> ) </td> </tr> </tbody> </table> </li> <li> <p> You can provide up to five VPC CIDRs. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> The <a href="https://registry.terraform.io/providers/RedisLabs/rediscloud/latest/docs"> Redis Cloud Terraform provider </a> currently supports one VPC CIDR. Additional CIDRs defined by the console will be removed by Terraform. </div> </div> <p> To add multiple VPC CIDRs: </p> <ol> <li> <p> Select <strong> Add CIDR </strong> . </p> </li> <li> <p> Enter additional CIDR-formatted IP address in the box: </p> <a href="/docs/latest/images/rc/subscription-connectivity-vpc-peering-add-multiple-cidrs.png" sdata-lightbox="/images/rc/subscription-connectivity-vpc-peering-add-multiple-cidrs.png"> <img alt="Select the Add CIDR button to add another VPC CIDR." src="/docs/latest/images/rc/subscription-connectivity-vpc-peering-add-multiple-cidrs.png" width="300px"/> </a> </li> </ol> </li> <li> <p> Select <strong> Initiate peering </strong> . </p> </li> <li> <p> Note the <strong> Peering ID </strong> of the VPC peering request. </p> <a href="/docs/latest/images/rc/subscription-connectivity-vpc-peering-aws.png" sdata-lightbox="/images/rc/subscription-connectivity-vpc-peering-aws.png"> <img alt="View VPC peering list." src="/docs/latest/images/rc/subscription-connectivity-vpc-peering-aws.png" width="350px"/> </a> </li> </ol> <h3 id="approve-aws-vpc-peering"> Approve VPC peering request </h3> <p> After you set up and intitiate VPC peering, you need to approve the VPC peering request: </p> <ol> <li> <p> Follow the AWS guide to <a href="https://docs.aws.amazon.com/vpc/latest/peering/accept-vpc-peering-connection.html"> accept the VPC peering connection </a> . </p> </li> <li> <p> After you accept the peering request, select <strong> Modify my route tables now </strong> . This button can be found in the green header once the peering connection is <strong> active </strong> . </p> </li> </ol> <a href="/docs/latest/images/rc/modify_route_tables_aws.png" sdata-lightbox="/images/rc/modify_route_tables_aws.png"> <img alt="Modify Route Table." src="/docs/latest/images/rc/modify_route_tables_aws.png" width="800px"/> </a> <h3 id="update-route-tables"> Update route tables </h3> <p> To finish VPC peering setup, <a href="https://docs.aws.amazon.com/vpc/latest/peering/vpc-peering-routing.html"> update your route tables for the peering connection </a> . There may be many different route tables assigned to different VPCs. It is important to choose the route table assigned to the VPC you specified in the <a href="#config-aws-vpc-peering"> Configure VPC Peering </a> section with the following details: </p> <ol> <li> <p> In the <strong> Destination </strong> field, enter the Requester VPC CIDRs shown when you accepted the peering request. </p> <p> This is the Redis Cloud VPC CIDR address, to which your application's VPC connects. </p> </li> <li> <p> In the <strong> Target </strong> field, select <strong> Peering Connection </strong> and select the relevant <strong> Peering ID </strong> . </p> </li> </ol> <p> Once VPC peering is established, we recommend switching your application connection string to the private endpoint. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> If you've enabled the database's <a href="/docs/latest/operate/rc/security/cidr-whitelist/"> CIDR allow list </a> , you must also <a href="/docs/latest/operate/rc/security/cidr-whitelist/#define-cidr-allow-list"> add the VPC peered IP addresses to the CIDR allow list </a> to connect to the database via the private endpoint. </div> </div> <h2 id="gcp-vpc-peering"> Google Cloud VPC peering </h2> <p> If you want to peer a Redis Cloud VPC with a Google Cloud VPC, you need to: </p> <ol> <li> <p> <a href="#config-gcp-vpc-peering"> Configure and initiate VPC peering </a> for your Redis Cloud subscription. </p> </li> <li> <p> <a href="#approve-gcp-vpc-peering"> Approve the VPC peering request </a> . </p> </li> </ol> <h3 id="config-gcp-vpc-peering"> Configure VPC peering </h3> <p> To set up VPC peering: </p> <ol> <li> <p> Select <strong> Subscriptions </strong> from the <a href="https://cloud.redis.io/"> Redis Cloud console </a> menu and then select your subscription from the list. </p> </li> <li> <p> Select <strong> Connectivity &gt; VPC Peering </strong> . </p> </li> <li> <p> Select <strong> Add peering </strong> . </p> </li> <li> <p> Enter the VPC peering details: </p> <table> <thead> <tr> <th> SettingΒ name </th> <th> Description </th> </tr> </thead> <tbody> <tr> <td> <strong> Project ID </strong> </td> <td> Google Cloud project ID (see <a href="https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects"> Identifying projects </a> ) </td> </tr> <tr> <td> <strong> Network name </strong> </td> <td> Google Cloud VPC network you want to peer with (see <a href="https://cloud.google.com/vpc/docs/create-modify-vpc-networks#viewing-networks"> View networks </a> ) </td> </tr> </tbody> </table> </li> <li> <p> Copy the <strong> Google cloud command </strong> after you enter the other VPC peering settings. You need this command to accept the peering request later: </p> <a href="/docs/latest/images/rc/subscription-connectivity-vpc-peering-gcloud-command.png" sdata-lightbox="/images/rc/subscription-connectivity-vpc-peering-gcloud-command.png"> <img alt="The Initiate peering button creates a VPC peering request." src="/docs/latest/images/rc/subscription-connectivity-vpc-peering-gcloud-command.png" width="350px"/> </a> </li> <li> <p> Select <strong> Initiate peering </strong> . </p> </li> <li> <p> Note the <strong> Cloud peering ID </strong> of the VPC peering request. </p> <a href="/docs/latest/images/rc/subscription-connectivity-vpc-peering-gcp.png" sdata-lightbox="/images/rc/subscription-connectivity-vpc-peering-gcp.png"> <img alt="View VPC peering list." src="/docs/latest/images/rc/subscription-connectivity-vpc-peering-gcp.png" width="350px"/> </a> </li> </ol> <h3 id="approve-gcp-vpc-peering"> Approve VPC peering request </h3> <p> To approve the VPC peering request between Redis Cloud and Google Cloud, use the <a href="https://cloud.google.com/sdk/gcloud"> <code> gcloud </code> CLI </a> to run the <strong> Google cloud command </strong> that you copied before you initiated VPC peering. </p> <p> Once VPC peering is established, we recommend switching your application connection string to the private endpoint. </p> <div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md"> <div class="p-2 pr-5"> <svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg"> <circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"> </circle> <path d="M10.5 14V16" stroke="currentColor" stroke-width="2"> </path> <path d="M10.5 5V12" stroke="currentColor" stroke-width="2"> </path> </svg> </div> <div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50"> <div class="font-medium"> Note: </div> If you've enabled the database's <a href="/docs/latest/operate/rc/security/cidr-whitelist/"> CIDR allow list </a> , you must also <a href="/docs/latest/operate/rc/security/cidr-whitelist/#define-cidr-allow-list"> add the VPC peered IP addresses to the CIDR allow list </a> to connect to the database via the private endpoint. </div> </div> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rc/security/vpc-peering/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>
https://redis.io/docs/latest/commands/command-docs/.html
<section class="prose w-full py-12"> <h1 class="command-name"> COMMAND DOCS </h1> <div class="font-semibold text-redis-ink-900"> Syntax </div> <pre class="command-syntax">COMMAND DOCS [command-name [command-name ...]]</pre> <dl class="grid grid-cols-[auto,1fr] gap-2 mb-12"> <dt class="font-semibold text-redis-ink-900 m-0"> Available since: </dt> <dd class="m-0"> 7.0.0 </dd> <dt class="font-semibold text-redis-ink-900 m-0"> Time complexity: </dt> <dd class="m-0"> O(N) where N is the number of commands to look up </dd> <dt class="font-semibold text-redis-ink-900 m-0"> ACL categories: </dt> <dd class="m-0"> <code> @slow </code> <span class="mr-1 last:hidden"> , </span> <code> @connection </code> <span class="mr-1 last:hidden"> , </span> </dd> </dl> <p> Return documentary information about commands. </p> <p> By default, the reply includes all of the server's commands. You can use the optional <em> command-name </em> argument to specify the names of one or more commands. </p> <p> The reply includes a map for each returned command. The following keys may be included in the mapped reply: </p> <ul> <li> <strong> summary: </strong> short command description. </li> <li> <strong> since: </strong> the Redis version that added the command (or for module commands, the module version). </li> <li> <strong> group: </strong> the functional group to which the command belongs. Possible values are: <ul> <li> <em> bitmap </em> </li> <li> <em> cluster </em> </li> <li> <em> connection </em> </li> <li> <em> generic </em> </li> <li> <em> geo </em> </li> <li> <em> hash </em> </li> <li> <em> hyperloglog </em> </li> <li> <em> list </em> </li> <li> <em> module </em> </li> <li> <em> pubsub </em> </li> <li> <em> scripting </em> </li> <li> <em> sentinel </em> </li> <li> <em> server </em> </li> <li> <em> set </em> </li> <li> <em> sorted-set </em> </li> <li> <em> stream </em> </li> <li> <em> string </em> </li> <li> <em> transactions </em> </li> </ul> </li> <li> <strong> complexity: </strong> a short explanation about the command's time complexity. </li> <li> <strong> doc_flags: </strong> an array of documentation flags. Possible values are: <ul> <li> <em> deprecated: </em> the command is deprecated. </li> <li> <em> syscmd: </em> a system command that isn't meant to be called by users. </li> </ul> </li> <li> <strong> deprecated_since: </strong> the Redis version that deprecated the command (or for module commands, the module version).. </li> <li> <strong> replaced_by: </strong> the alternative for a deprecated command. </li> <li> <strong> history: </strong> an array of historical notes describing changes to the command's output or arguments. It should not contain information about behavioral changes. Each entry is an array itself, made up of two elements: <ol> <li> The Redis version that the entry applies to. </li> <li> The description of the change. </li> </ol> </li> <li> <strong> arguments: </strong> an array of maps that describe the command's arguments. Please refer to the <a href="/develop/reference/command-arguments"> Redis command arguments </a> page for more information. </li> </ul> <h2 id="examples"> Examples </h2> <div class="bg-slate-900 border-b border-slate-700 rounded-t-xl px-4 py-3 w-full flex"> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10Z"> </path> </svg> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M10 2.5L18.6603 17.5L1.33975 17.5L10 2.5Z"> </path> </svg> <svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20"> <path d="M10 2.5L12.0776 7.9322L17.886 8.22949L13.3617 11.8841L14.8738 17.5L10 14.3264L5.1262 17.5L6.63834 11.8841L2.11403 8.22949L7.92238 7.9322L10 2.5Z"> </path> </svg> </div> <form class="redis-cli overflow-y-auto max-h-80"> <pre tabindex="0">redis&gt; COMMAND DOCS SET 1) "set" 2) 1) "summary" 2) "Sets the string value of a key, ignoring its type. The key is created if it doesn't exist." 3) "since" 4) "1.0.0" 5) "group" 6) "string" 7) "complexity" 8) "O(1)" 9) "history" 10) 1) 1) "2.6.12" 2) "Added the `EX`, `PX`, `NX` and `XX` options." 2) 1) "6.0.0" 2) "Added the `KEEPTTL` option." 3) 1) "6.2.0" 2) "Added the `GET`, `EXAT` and `PXAT` option." 4) 1) "7.0.0" 2) "Allowed the `NX` and `GET` options to be used together." 11) "arguments" 12) 1) 1) "name" 2) "key" 3) "type" 4) "key" 5) "display_text" 6) "key" 7) "key_spec_index" 8) (integer) 0 2) 1) "name" 2) "value" 3) "type" 4) "string" 5) "display_text" 6) "value" 3) 1) "name" 2) "condition" 3) "type" 4) "oneof" 5) "since" 6) "2.6.12" 7) "flags" 8) 1) "optional" 9) "arguments" 10) 1) 1) "name" 2) "nx" 3) "type" 4) "pure-token" 5) "display_text" 6) "nx" 7) "token" 8) "NX" 2) 1) "name" 2) "xx" 3) "type" 4) "pure-token" 5) "display_text" 6) "xx" 7) "token" 8) "XX" 4) 1) "name" 2) "get" 3) "type" 4) "pure-token" 5) "display_text" 6) "get" 7) "token" 8) "GET" 9) "since" 10) "6.2.0" 11) "flags" 12) 1) "optional" 5) 1) "name" 2) "expiration" 3) "type" 4) "oneof" 5) "flags" 6) 1) "optional" 7) "arguments" 8) 1) 1) "name" 2) "seconds" 3) "type" 4) "integer" 5) "display_text" 6) "seconds" 7) "token" 8) "EX" 9) "since" 10) "2.6.12" 2) 1) "name" 2) "milliseconds" 3) "type" 4) "integer" 5) "display_text" 6) "milliseconds" 7) "token" 8) "PX" 9) "since" 10) "2.6.12" 3) 1) "name" 2) "unix-time-seconds" 3) "type" 4) "unix-time" 5) "display_text" 6) "unix-time-seconds" 7) "token" 8) "EXAT" 9) "since" 10) "6.2.0" 4) 1) "name" 2) "unix-time-milliseconds" 3) "type" 4) "unix-time" 5) "display_text" 6) "unix-time-milliseconds" 7) "token" 8) "PXAT" 9) "since" 10) "6.2.0" 5) 1) "name" 2) "keepttl" 3) "type" 4) "pure-token" 5) "display_text" 6) "keepttl" 7) "token" 8) "KEEPTTL" 9) "since" 10) "6.0.0" </pre> <div class="prompt" style=""> <span> redis&gt; </span> <input autocomplete="off" name="prompt" spellcheck="false" type="text"/> </div> </form> <h2 id="resp2-reply"> RESP2 Reply </h2> <a href="../../develop/reference/protocol-spec#arrays"> Array reply </a> : a map, as a flattened array, where each key is a command name, and each value is the documentary information. <h2 id="resp3-reply"> RESP3 Reply </h2> <a href="../../develop/reference/protocol-spec#maps"> Map reply </a> : a map where each key is a command name, and each value is the documentary information. <br/> <form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback"> <input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/command-docs/"/> <div class="flex flex-row justify-between"> <div class="grid justify-center"> <span class="font-mono"> RATE THIS PAGE </span> <div class="star-rating"> <input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/> <label class="star" for="5-stars"> β˜… </label> <input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/> <label class="star" for="4-stars"> β˜… </label> <input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/> <label class="star" for="3-stars"> β˜… </label> <input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/> <label class="star" for="2-stars"> β˜… </label> <input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/> <label class="star" for="1-stars"> β˜… </label> </div> </div> <a class="font-mono no-underline" href="#"> Back to top ↑ </a> </div> <div class="hidden" id="feedback-form"> <div class="grid gap-2"> <textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea> <button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit"> Submit </button> </div> </div> </form> <script> document.addEventListener("DOMContentLoaded", function() { const form = document.querySelector("#page-feedback"); form.addEventListener("submit", function(event) { event.preventDefault(); var xhr = new XMLHttpRequest(); var url = "\/docusight\/api\/rate"; var params = new URLSearchParams(new FormData(form)); xhr.open("POST", url, true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState === 4 && xhr.status === 200) { const responseData = JSON.parse(xhr.responseText); const responseMessage = responseData.response; const newText = document.createTextNode(responseMessage); form.parentNode.replaceChild(newText, form); } }; xhr.send(params); }); }); </script> </section>