url
stringlengths 38
157
| content
stringlengths 72
15.1M
|
---|---|
https://redis.io/docs/latest/operate/rs/7.4/installing-upgrading/upgrading/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Upgrade an existing Redis Enterprise Software deployment
</h1>
<p>
To upgrade Redis Enterprise Software:
</p>
<ol>
<li>
<p>
Verify appropriate
<a href="/docs/latest/operate/rs/7.4/networking/port-configurations/">
network ports
</a>
are either open or used by Redis Enterprise Software.
</p>
</li>
<li>
<p>
<a href="/docs/latest/operate/rs/7.4/installing-upgrading/upgrading/upgrade-cluster/">
Upgrade the software on all nodes of the cluster.
</a>
</p>
</li>
<li>
<p>
<em>
(Optional)
</em>
<a href="/docs/latest/operate/rs/7.4/installing-upgrading/upgrading/upgrade-database/">
Upgrade each database
</a>
in the cluster or
<a href="/docs/latest/operate/rs/7.4/installing-upgrading/upgrading/upgrade-active-active/">
upgrade an Active-Active database
</a>
to enable new features and important fixes.
</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/7.4/installing-upgrading/upgrading/"/>
<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/mget/.html | <section class="prose w-full py-12">
<h1 class="command-name">
MGET
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">MGET key [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 number of keys to retrieve.
</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>
Returns the values of all specified keys.
For every key that does not hold a string value or does not exist, the special
value
<code>
nil
</code>
is returned.
Because of this, the operation never fails.
</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> SET key1 "Hello"
"OK"
redis> SET key2 "World"
"OK"
redis> MGET key1 key2 nonexisting
1) "Hello"
2) "World"
3) (nil)
</pre>
<div class="prompt" style="">
<span>
redis>
</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 values at the specified keys.
<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/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/commands/cf.mexists/.html | <section class="prose w-full py-12">
<h1 class="command-name">
CF.MEXISTS
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">CF.MEXISTS 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 1.0.0
</a>
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(k * n), where k is the number of sub-filters and n is the number of items
</dd>
</dl>
<p>
Determines whether one or more items were added to a cuckoo filter.
</p>
<p>
This command is similar to
<a href="/docs/latest/commands/cf.exists/">
<code>
CF.EXISTS
</code>
</a>
, except that more than one item can be checked.
</p>
<h2 id="required-arguments">
Required arguments
</h2>
<details open="">
<summary>
<code>
key
</code>
</summary>
<p>
is key name for a cuckoo filter.
</p>
</details>
<details open="">
<summary>
<code>
item...
</code>
</summary>
<p>
One or more items to check.
</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/#arrays">
Array reply
</a>
of
<a href="/docs/latest/develop/reference/protocol-spec/#integers">
Integer reply
</a>
- where "1" means that, with high probability,
<code>
item
</code>
was already added to the filter, and "0" means that
<code>
key
</code>
does not exist or that
<code>
item
</code>
had not added to the filter. See note in
<a href="/docs/latest/commands/cf.del/">
<code>
CF.DEL
</code>
</a>
.
</li>
<li>
[] on error (invalid arguments, wrong key type, etc.)
</li>
</ul>
<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> CF.INSERT cf ITEMS item1 item2
</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> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1</span>
</span></span><span class="line"><span class="cl">redis> CF.MEXISTS cf item1 item2 item3
</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> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1</span>
</span></span><span class="line"><span class="cl">3<span class="o">)</span> <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/cf.mexists/"/>
<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.reserve.html | <section class="prose w-full py-12">
<h1 class="command-name">
BF.RESERVE
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">BF.RESERVE key error_rate capacity [EXPANSIONΒ expansion]
[NONSCALING]</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(1)
</dd>
</dl>
<p>
Creates an empty Bloom filter with a single sub-filter for the initial specified capacity and with an upper bound
<code>
error_rate
</code>
.
</p>
<p>
By default, the filter auto-scales by creating additional sub-filters when
<code>
capacity
</code>
is reached.
The new sub-filter is created with size of the previous sub-filter multiplied by
<code>
expansion
</code>
.
</p>
<p>
Though the filter can scale up by creating sub-filters, it is recommended to reserve the estimated required
<code>
capacity
</code>
since maintaining and querying
sub-filters requires additional memory (each sub-filter uses an extra bits and hash function) and consume further CPU time than an equivalent filter that had
the right capacity at creation time.
</p>
<p>
The number of hash functions is
<code>
-log(error)/ln(2)^2
</code>
.
The number of bits per item is
<code>
-log(error)/ln(2)
</code>
β 1.44.
</p>
<ul>
<li>
<strong>
1%
</strong>
error rate requires 7 hash functions and 10.08 bits per item.
</li>
<li>
<strong>
0.1%
</strong>
error rate requires 10 hash functions and 14.4 bits per item.
</li>
<li>
<strong>
0.01%
</strong>
error rate requires 14 hash functions and 20.16 bits per item.
</li>
</ul>
<h2 id="required-arguments">
Required arguments
</h2>
<details open="">
<summary>
<code>
key
</code>
</summary>
<p>
is key name for the the Bloom filter to be created.
</p>
</details>
<details open="">
<summary>
<code>
error_rate
</code>
</summary>
<p>
The desired probability for false positives. The rate is a decimal value between 0 and 1.
For example, for a desired false positive rate of 0.1% (1 in 1000), error_rate should be set to 0.001.
</p>
</details>
<details open="">
<summary>
<code>
capacity
</code>
</summary>
<p>
The number of entries intended to be added to the filter.
If your filter allows scaling, performance will begin to degrade after adding more items than this number.
The actual degradation depends on how far the limit has been exceeded. Performance degrades linearly with the number of
<code>
sub-filters
</code>
.
</p>
</details>
<h2 id="optional-arguments">
Optional arguments
</h2>
<details open="">
<summary>
<code>
NONSCALING
</code>
</summary>
<p>
Prevents the filter from creating additional sub-filters if initial capacity is reached.
Non-scaling filters requires slightly less memory than their scaling counterparts. The filter returns an error when
<code>
capacity
</code>
is reached.
</p>
</details>
<details open="">
<summary>
<code>
EXPANSION expansion
</code>
</summary>
<p>
When
<code>
capacity
</code>
is reached, an additional sub-filter is created.
The size of the new sub-filter is the size of the last sub-filter multiplied by
<code>
expansion
</code>
, specified as a positive integer.
</p>
<p>
If the number of elements to be stored in the filter is unknown, you use an
<code>
expansion
</code>
of
<code>
2
</code>
or more to reduce the number of sub-filters.
Otherwise, you use an
<code>
expansion
</code>
of
<code>
1
</code>
to reduce memory consumption. The default value is
<code>
2
</code>
.
</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 filter created successfully
</li>
<li>
[] on error (invalid arguments, key already exists, etc.)
</li>
</ul>
<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> BF.RESERVE bf 0.01 <span class="m">1000</span>
</span></span><span class="line"><span class="cl">OK</span></span></code></pre>
</div>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> BF.RESERVE bf 0.01 <span class="m">1000</span>
</span></span><span class="line"><span class="cl"><span class="o">(</span>error<span class="o">)</span> ERR item exists</span></span></code></pre>
</div>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> BF.RESERVE bf_exp 0.01 <span class="m">1000</span> EXPANSION <span class="m">2</span>
</span></span><span class="line"><span class="cl">OK</span></span></code></pre>
</div>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> BF.RESERVE bf_non 0.01 <span class="m">1000</span> NONSCALING
</span></span><span class="line"><span class="cl">OK</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.reserve/"/>
<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/modules/config/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Configure module requests
</h1>
<p class="text-lg -mt-5 mb-10">
Configure module requests
</p>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="#post-modules-config-bdb">
POST
</a>
</td>
<td>
<code>
/v1/modules/config/bdb/{uid}
</code>
</td>
<td>
Configure module
</td>
</tr>
</tbody>
</table>
<h2 id="post-modules-config-bdb">
Configure module
</h2>
<pre><code>POST /v1/modules/config/bdb/{string: uid}
</code></pre>
<p>
Use the module runtime configuration command (if defined) to configure new arguments for the module.
</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/#edit_bdb_module">
edit_bdb_module
</a>
</td>
</tr>
</tbody>
</table>
<h3 id="post-request">
Request
</h3>
<h4 id="example-http-request">
Example HTTP request
</h4>
<pre><code>POST /modules/config/bdb/1
</code></pre>
<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">"modules"</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">"module_name"</span><span class="p">:</span> <span class="s2">"search"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"module_args"</span><span class="p">:</span> <span class="s2">"MINPREFIX 3 MAXEXPANSIONS 1000"</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><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="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>
<h4 id="request-body">
Request body
</h4>
<table>
<thead>
<tr>
<th>
Field
</th>
<th>
Type
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
modules
</td>
<td>
list of JSON objects
</td>
<td>
List of modules (module_name) and their new configuration settings (module_args)
</td>
</tr>
<tr>
<td>
module_name
</td>
<td>
<code>
search
</code>
<br/>
<code>
ReJSON
</code>
<br/>
<code>
graph
</code>
<br/>
<code>
timeseries
</code>
<br/>
<code>
bf
</code>
</td>
<td>
Module's name
</td>
</tr>
<tr>
<td>
module_args
</td>
<td>
string
</td>
<td>
Module command line arguments (pattern does not allow special characters &,<,>,β)
</td>
</tr>
</tbody>
</table>
<h3 id="post-response">
Response
</h3>
<p>
Returns a status code. If an error occurs, the response body may include an error code and message with more details.
</p>
<h3 id="post-error-codes">
Error codes
</h3>
<p>
When errors are reported, the server may return a JSON object with
<code>
error_code
</code>
and
<code>
message
</code>
field that provide additional information. The following are possible
<code>
error_code
</code>
values:
</p>
<table>
<thead>
<tr>
<th>
Code
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
db_not_exist
</td>
<td>
Database with given UID doesn't exist in cluster
</td>
</tr>
<tr>
<td>
missing_field
</td>
<td>
"module_name" or "module_args" are not defined in request
</td>
</tr>
<tr>
<td>
invalid_schema
</td>
<td>
JSON object received is not a dict object
</td>
</tr>
<tr>
<td>
param_error
</td>
<td>
"module_args" parameter was not parsed properly
</td>
</tr>
<tr>
<td>
module_not_exist
</td>
<td>
Module with given "module_name" does not exist for the database
</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>
Success, module updated on bdb.
</td>
</tr>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5">
404 Not Found
</a>
</td>
<td>
bdb not found.
</td>
</tr>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1">
400 Bad Request
</a>
</td>
<td>
Bad or missing configuration parameters.
</td>
</tr>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.7">
406 Not Acceptable
</a>
</td>
<td>
Module does not support runtime configuration of arguments.
</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/modules/config/"/>
<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/persist/.html | <section class="prose w-full py-12">
<h1 class="command-name">
PERSIST
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">PERSIST 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.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>
@keyspace
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@write
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@fast
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
Remove the existing timeout on
<code>
key
</code>
, turning the key from
<em>
volatile
</em>
(a key
with an expire set) to
<em>
persistent
</em>
(a key that will never expire as no timeout
is associated).
</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> SET mykey "Hello"
"OK"
redis> EXPIRE mykey 10
(integer) 1
redis> TTL mykey
(integer) 10
redis> PERSIST mykey
(integer) 1
redis> TTL mykey
(integer) -1
</pre>
<div class="prompt" style="">
<span>
redis>
</span>
<input autocomplete="off" name="prompt" spellcheck="false" type="text"/>
</div>
</form>
<h2 id="resp2resp3-reply">
RESP2/RESP3 Reply
</h2>
<p>
One of the following:
</p>
<ul>
<li>
<a href="../../develop/reference/protocol-spec#integers">
Integer reply
</a>
:
<code>
0
</code>
if
<em>
key
</em>
does not exist or does not have an associated timeout.
</li>
<li>
<a href="../../develop/reference/protocol-spec#integers">
Integer reply
</a>
:
<code>
1
</code>
if the timeout has been removed.
</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/persist/"/>
<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/data-access-control/active-active-roles/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Create roles for Active-Active databases
</h1>
<p>
For
<a href="/docs/latest/operate/rc/databases/configuration/active-active-redis/">
Active-Active databases
</a>
, you can define roles with different levels of access for different regions. For example, you can define a user role with full database access in one region and read-only access in another. Or, you can prevent a user from running any commands in a specified region.
</p>
<ol>
<li>
<p>
Go to
<strong>
Data Access Control > Roles
</strong>
and either select
<code>
+
</code>
to create a new role or point to an existing role and select the pencil icon to edit it.
</p>
</li>
<li>
<p>
In the
<strong>
Associations
</strong>
section of the
<strong>
Edit role
</strong>
or
<strong>
Create new role
</strong>
screen, you can select
<code>
+
</code>
to create a new association or point to an existing association and select the pencil icon to edit it.
</p>
</li>
<li>
<p>
Select one or more Active-Active databases from the
<strong>
Databases
</strong>
list. Active-Active databases are marked with a globe icon.
</p>
<a href="/docs/latest/images/rc/roles-select-aa-database.png" sdata-lightbox="/images/rc/roles-select-aa-database.png">
<img alt="List of databases. Active-Active databases are marked with a globe icon." src="/docs/latest/images/rc/roles-select-aa-database.png"/>
</a>
</li>
<li>
<p>
To set the role's default level of access to the selected databases, choose a
<strong>
Redis ACL
</strong>
from the list and select the check mark to confirm the association.
</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 level of access to the selected database only applies to regions that exist when the role is created. If you add a new region to your Active-Active subscription, the new region will default to
<strong>
No Access
</strong>
for the role.
</div>
</div>
</li>
<li>
<p>
Select the ACL name next to a region to change which ACL applies to that region.
</p>
<a href="/docs/latest/images/rc/roles-assign-rules-active-active.png" sdata-lightbox="/images/rc/roles-assign-rules-active-active.png">
<img alt="Assign different ACL rules for different regions." src="/docs/latest/images/rc/roles-assign-rules-active-active.png"/>
</a>
<p>
In addition to the ACL rules that are already configured, you can set a role to have
<strong>
No-Access
</strong>
in a region. This is a special rule that prevents a user with this role from running any commands when connecting to the database in that region.
</p>
</li>
<li>
<p>
Select
<strong>
Save role
</strong>
.
</p>
</li>
</ol>
<p>
When you assign a user-defined ACL rule to a role and associate it with one or more databases, Redis will verify that the ACL rule will work with the selected databases. Verify that the
<a href="/docs/latest/operate/rc/security/access-control/data-access-control/configure-acls/#define-permissions-with-acl-syntax">
syntax
</a>
of the ACL rule is correct if you receive an error.
</p>
<p>
After you create a role, you can assign it to a user. Users with this role can access the databases according to the role's associated Redis ACLs. For more information, see
<a href="/docs/latest/operate/rc/security/access-control/data-access-control/create-assign-users/#assign-roles-to-existing-users">
Assign roles to users
</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>
Applying ACLs to the database is an asynchronous operation. You may notice a delay before an ACL is fully applied to the database.
</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/access-control/data-access-control/active-active-roles/"/>
<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/clusters/optimize/memtier-benchmark/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Benchmarking Redis Enterprise
</h1>
<p class="text-lg -mt-5 mb-10">
Use the
<code>
memtier_benchmark
</code>
tool to perform a performance benchmark of Redis Enterprise Software.
</p>
<p>
Use the
<code>
memtier_benchmark
</code>
tool to perform a performance benchmark of Redis Enterprise Software.
</p>
<p>
Prerequisites:
</p>
<ul>
<li>
Redis Enterprise Software installed
</li>
<li>
A cluster configured
</li>
<li>
A database created
</li>
</ul>
<p>
For help with the prerequisites, see the
<a href="/docs/latest/operate/rs/installing-upgrading/quickstarts/redis-enterprise-software-quickstart/">
Redis Enterprise Software quickstart
</a>
.
</p>
<p>
It is recommended to run memtier_benchmark on a separate node that is
not part of the cluster being tested. If you run it on a node of the
cluster, be mindful that it affects the performance of both the
cluster and memtier_benchmark.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">/opt/redislabs/bin/memtier_benchmark -s <span class="nv">$DB_HOST</span> -p <span class="nv">$DB_PORT</span> -a <span class="nv">$DB_PASSWORD</span> -t <span class="m">4</span> -R --ratio<span class="o">=</span>1:1
</span></span></code></pre>
</div>
<p>
This command instructs memtier_benchmark to connect to your Redis
Enterprise database and generates a load doing the following:
</p>
<ul>
<li>
A 50/50 Set to Get ratio
</li>
<li>
Each object has random data in the value
</li>
</ul>
<h2 id="populate-a-database-with-testing-data">
Populate a database with testing data
</h2>
<p>
If you need to populate a database with some test data for a proof of
concept, or failover testing, etc. here is an example for you.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">/opt/redislabs/bin/memtier_benchmark -s <span class="nv">$DB_HOST</span> -p <span class="nv">$DB_PORT</span> -a <span class="nv">$DB_PASSWORD</span> -R -n allkeys -d <span class="m">500</span> --key-pattern<span class="o">=</span>P:P --ratio<span class="o">=</span>1:0
</span></span></code></pre>
</div>
<p>
This command instructs memtier_benchmark to connect to your Redis
Enterprise database and generates a load doing the following:
</p>
<ul>
<li>
Write objects only, no reads
</li>
<li>
A 500 byte object
</li>
<li>
Each object has random data in the value
</li>
<li>
Each key has a random pattern, then a colon, followed by a
random pattern.
</li>
</ul>
<p>
Run this command until it fills up your database to where you want it
for testing. The easiest way to check is on the database metrics page.
</p>
<a href="/docs/latest/images/rs/memtier_metrics_page.png" sdata-lightbox="/images/rs/memtier_metrics_page.png">
<img src="/docs/latest/images/rs/memtier_metrics_page.png"/>
</a>
<p>
Another use for memtier_benchmark is to populate a database with data
for failure testing.
</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/clusters/optimize/memtier-benchmark/"/>
<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/hpttl/.html | <section class="prose w-full py-12">
<h1 class="command-name">
HPTTL
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">HPTTL key FIELDS numfields field [field ...]</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.4.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 arguments to the command
</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>
@hash
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@fast
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
Like
<a href="/docs/latest/commands/httl/">
<code>
HTTL
</code>
</a>
, this command returns the remaining TTL (time to live) of a field that has an
expiration set, but in milliseconds instead of seconds.
</p>
<h2 id="example">
Example
</h2>
<pre tabindex="0"><code>redis> HPTTL no-key FIELDS 3 field1 field2 field3
(nil)
redis> HSET mykey field1 "hello" field2 "world"
(integer) 2
redis> HEXPIRE mykey 300 FIELDS 2 field1 field3
1) (integer) 1
2) (integer) -2
redis> HPTTL mykey FIELDS 3 field1 field2 field3
1) (integer) 292202
2) (integer) -1
3) (integer) -2
</code></pre>
<h2 id="resp2resp3-reply">
RESP2/RESP3 Reply
</h2>
<ul>
<li>
<a href="../../develop/reference/protocol-spec#arrays">
Array reply
</a>
. For each field:
<ul>
<li>
<a href="../../develop/reference/protocol-spec#integers">
Integer reply
</a>
:
<code>
-2
</code>
if no such field exists in the provided hash key, or the provided key does not exist.
</li>
<li>
<a href="../../develop/reference/protocol-spec#integers">
Integer reply
</a>
:
<code>
-1
</code>
if the field exists but has no associated expiration set.
</li>
<li>
<a href="../../develop/reference/protocol-spec#integers">
Integer reply
</a>
: the TTL in milliseconds.
</li>
</ul>
</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/hpttl/"/>
<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/shards/stats/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Shards stats requests
</h1>
<p class="text-lg -mt-5 mb-10">
Shard statistics requests
</p>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="#get-all-shards-stats">
GET
</a>
</td>
<td>
<code>
/v1/shards/stats
</code>
</td>
<td>
Get stats for all shards
</td>
</tr>
<tr>
<td>
<a href="#get-shard-stats">
GET
</a>
</td>
<td>
<code>
/v1/shards/stats/{uid}
</code>
</td>
<td>
Get stats for a specific shard
</td>
</tr>
</tbody>
</table>
<h2 id="get-all-shards-stats">
Get all shards stats
</h2>
<pre><code>GET /v1/shards/stats
</code></pre>
<p>
Get statistics for all shards.
</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_all_shard_stats">
view_all_shard_stats
</a>
</td>
</tr>
</tbody>
</table>
<h3 id="get-all-request">
Request
</h3>
<h4 id="example-http-request">
Example HTTP request
</h4>
<pre><code>GET /shards/stats?interval=1hour&stime=2014-08-28T10:00:00Z
</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>
<h4 id="query-parameters">
Query parameters
</h4>
<table>
<thead>
<tr>
<th>
Field
</th>
<th>
Type
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
parent_uid
</td>
<td>
integer
</td>
<td>
Only return shard from the given BDB ID (optional)
</td>
</tr>
<tr>
<td>
interval
</td>
<td>
string
</td>
<td>
Time interval for which we want stats: 1sec/10sec/5min/15min/1hour/12hour/1week (optional)
</td>
</tr>
<tr>
<td>
stime
</td>
<td>
ISO_8601
</td>
<td>
Start time from which we want the stats. Should comply with the
<a href="https://en.wikipedia.org/wiki/ISO_8601">
ISO_8601
</a>
format (optional)
</td>
</tr>
<tr>
<td>
etime
</td>
<td>
ISO_8601
</td>
<td>
End time after which we don't want the stats. Should comply with the
<a href="https://en.wikipedia.org/wiki/ISO_8601">
ISO_8601
</a>
format (optional)
</td>
</tr>
<tr>
<td>
metrics
</td>
<td>
list
</td>
<td>
Comma-separated list of
<a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/statistics/shard-metrics/">
metric names
</a>
for which we want statistics (default is all) (optional)
</td>
</tr>
</tbody>
</table>
<h3 id="get-all-response">
Response
</h3>
<p>
Returns a JSON array of
<a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/statistics/">
statistics
</a>
for all shards.
</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">"status"</span><span class="p">:</span> <span class="s2">"active"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"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">"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">"assigned_slots"</span><span class="p">:</span> <span class="s2">"0-8191"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"intervals"</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">"interval"</span><span class="p">:</span> <span class="s2">"1sec"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"stime"</span><span class="p">:</span> <span class="s2">"2015-05-28T08:27:35Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"etime"</span><span class="p">:</span> <span class="s2">"2015-05-28T08:27:40Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"used_memory_peak"</span><span class="p">:</span> <span class="mf">5888264.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"used_memory_rss"</span><span class="p">:</span> <span class="mf">5888264.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"read_hits"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"pubsub_patterns"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"no_of_keys"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"mem_size_lua"</span><span class="p">:</span> <span class="mf">35840.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"last_save_time"</span><span class="p">:</span> <span class="mf">1432541051.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"sync_partial_ok"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"connected_clients"</span><span class="p">:</span> <span class="mf">9.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"avg_ttl"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"write_misses"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"used_memory"</span><span class="p">:</span> <span class="mf">5651440.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"sync_full"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"expired_objects"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"total_req"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"blocked_clients"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"pubsub_channels"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"evicted_objects"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"no_of_expires"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"interval"</span><span class="p">:</span> <span class="s2">"1sec"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"write_hits"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"read_misses"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"sync_partial_err"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"rdb_changes_since_last_save"</span><span class="p">:</span> <span class="mf">0.0</span>
</span></span><span class="line"><span class="cl"> <span class="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">"interval"</span><span class="p">:</span> <span class="s2">"1sec"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"stime"</span><span class="p">:</span> <span class="s2">"2015-05-28T08:27:40Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"etime"</span><span class="p">:</span> <span class="s2">"2015-05-28T08:27:45Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"// additional fields..."</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl"> <span class="p">]</span>
</span></span><span class="line"><span class="cl"> <span class="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">"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">"status"</span><span class="p">:</span> <span class="s2">"active"</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">"assigned_slots"</span><span class="p">:</span> <span class="s2">"8192-16383"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"intervals"</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">"interval"</span><span class="p">:</span> <span class="s2">"1sec"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"stime"</span><span class="p">:</span> <span class="s2">"2015-05-28T08:27:35Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"etime"</span><span class="p">:</span> <span class="s2">"2015-05-28T08:27:40Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"// additional fields..."</span>
</span></span><span class="line"><span class="cl"> <span class="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">"interval"</span><span class="p">:</span> <span class="s2">"1sec"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"stime"</span><span class="p">:</span> <span class="s2">"2015-05-28T08:27:40Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"etime"</span><span class="p">:</span> <span class="s2">"2015-05-28T08:27:45Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"// additional fields..."</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl"> <span class="p">]</span>
</span></span><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>
<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="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>
No shards exist
</td>
</tr>
</tbody>
</table>
<h2 id="get-shard-stats">
Get shard stats
</h2>
<pre><code>GET /v1/shards/stats/{int: uid}
</code></pre>
<p>
Get statistics for a specific shard.
</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/#view_shard_stats">
view_shard_stats
</a>
</td>
</tr>
</tbody>
</table>
<h3 id="get-request">
Request
</h3>
<h4 id="example-http-request-1">
Example HTTP request
</h4>
<pre><code>GET /shards/stats/1?interval=1hour&stime=2014-08-28T10:00:00Z
</code></pre>
<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>
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 shard requested.
</td>
</tr>
</tbody>
</table>
<h4 id="query-parameters-1">
Query parameters
</h4>
<table>
<thead>
<tr>
<th>
Field
</th>
<th>
Type
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
interval
</td>
<td>
string
</td>
<td>
Time interval for which we want stats: 1sec/10sec/5min/15min/1hour/12hour/1week (optional)
</td>
</tr>
<tr>
<td>
stime
</td>
<td>
ISO_8601
</td>
<td>
Start time from which we want the stats. Should comply with the
<a href="https://en.wikipedia.org/wiki/ISO_8601">
ISO_8601
</a>
format (optional)
</td>
</tr>
<tr>
<td>
etime
</td>
<td>
ISO_8601
</td>
<td>
End time after which we don't want the stats. Should comply with the
<a href="https://en.wikipedia.org/wiki/ISO_8601">
ISO_8601
</a>
format (optional)
</td>
</tr>
</tbody>
</table>
<h3 id="get-response">
Response
</h3>
<p>
Returns
<a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/statistics/">
statistics
</a>
for the specified shard.
</p>
<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">"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">"status"</span><span class="p">:</span> <span class="s2">"active"</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">"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">"intervals"</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">"interval"</span><span class="p">:</span> <span class="s2">"1sec"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"stime"</span><span class="p">:</span> <span class="s2">"2015-05-28T08:24:13Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"etime"</span><span class="p">:</span> <span class="s2">"2015-05-28T08:24:18Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"avg_ttl"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"blocked_clients"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"connected_clients"</span><span class="p">:</span> <span class="mf">9.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"etime"</span><span class="p">:</span> <span class="s2">"2015-05-28T08:24:18Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"evicted_objects"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"expired_objects"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"last_save_time"</span><span class="p">:</span> <span class="mf">1432541051.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"used_memory"</span><span class="p">:</span> <span class="mf">5651440.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"mem_size_lua"</span><span class="p">:</span> <span class="mf">35840.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"used_memory_peak"</span><span class="p">:</span> <span class="mf">5888264.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"used_memory_rss"</span><span class="p">:</span> <span class="mf">5888264.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"no_of_expires"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"no_of_keys"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"pubsub_channels"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"pubsub_patterns"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"rdb_changes_since_last_save"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"read_hits"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"read_misses"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"stime"</span><span class="p">:</span> <span class="s2">"2015-05-28T08:24:13Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"sync_full"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"sync_partial_err"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"sync_partial_ok"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"total_req"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"write_hits"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"write_misses"</span><span class="p">:</span> <span class="mf">0.0</span>
</span></span><span class="line"><span class="cl"> <span class="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">"interval"</span><span class="p">:</span> <span class="s2">"1sec"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"stime"</span><span class="p">:</span> <span class="s2">"2015-05-28T08:24:18Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"etime"</span><span class="p">:</span> <span class="s2">"2015-05-28T08:24:23Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nt">"// additional fields..."</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><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>
<h3 id="get-status-codes">
Status codes
</h3>
<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>
Shard does not exist
</td>
</tr>
<tr>
<td>
<a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-406-not-acceptable">
406 Not Acceptable
</a>
</td>
<td>
Shard isn't currently active
</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/shards/stats/"/>
<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/client-no-touch/.html | <section class="prose w-full py-12">
<h1 class="command-name">
CLIENT NO-TOUCH
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">CLIENT NO-TOUCH <ON | OFF></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.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>
@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 NO-TOUCH
</code>
command controls whether commands sent by the client will alter the LRU/LFU of the keys they access.
</p>
<p>
When turned on, the current client will not change LFU/LRU stats, unless it sends the
<a href="/docs/latest/commands/touch/">
<code>
TOUCH
</code>
</a>
command.
</p>
<p>
When turned off, the client touches LFU/LRU stats just as a normal client.
</p>
<h2 id="resp2resp3-reply">
RESP2/RESP3 Reply
</h2>
<a href="../../develop/reference/protocol-spec#simple-strings">
Simple string reply
</a>
:
<code>
OK
</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/client-no-touch/"/>
<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/bitmaps/.html | <section class="prose w-full py-12">
<h1>
Redis bitmaps
</h1>
<p class="text-lg -mt-5 mb-10">
Introduction to Redis bitmaps
</p>
<p>
Bitmaps are not an actual data type, but a set of bit-oriented operations
defined on the String type which is treated like a bit vector.
Since strings are binary safe blobs and their maximum length is 512 MB,
they are suitable to set up to 2^32 different bits.
</p>
<p>
You can perform bitwise operations on one or more strings.
Some examples of bitmap use cases include:
</p>
<ul>
<li>
Efficient set representations for cases where the members of a set correspond to the integers 0-N.
</li>
<li>
Object permissions, where each bit represents a particular permission, similar to the way that file systems store permissions.
</li>
</ul>
<h2 id="basic-commands">
Basic commands
</h2>
<ul>
<li>
<a href="/docs/latest/commands/setbit/">
<code>
SETBIT
</code>
</a>
sets a bit at the provided offset to 0 or 1.
</li>
<li>
<a href="/docs/latest/commands/getbit/">
<code>
GETBIT
</code>
</a>
returns the value of a bit at a given offset.
</li>
</ul>
<p>
See the
<a href="/docs/latest/commands/?group=bitmap">
complete list of bitmap commands
</a>
.
</p>
<h2 id="example">
Example
</h2>
<p>
Suppose you have 1000 cyclists racing through the country-side, with sensors on their bikes labeled 0-999.
You want to quickly determine whether a given sensor has pinged a tracking server within the hour to check in on a rider.
</p>
<p>
You can represent this scenario using a bitmap whose key references the current hour.
</p>
<ul>
<li>
Rider 123 pings the server on January 1, 2024 within the 00:00 hour. You can then confirm that rider 123 pinged the server. You can also check to see if rider 456 has pinged the server for that same hour.
</li>
</ul>
<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="bitmap_tutorial-stepping">
<input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_bitmap_tutorial-stepping" name="bitmap_tutorial-stepping" 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_bitmap_tutorial-stepping" title="Open example">
>_ Redis CLI
</label>
<div aria-labelledby="tab-bitmap_tutorial-stepping" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_bitmap_tutorial-stepping" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">> SETBIT pings:2024-01-01-00:00 123 1
</span></span><span class="line hl"><span class="cl">(integer) 0
</span></span><span class="line hl"><span class="cl">> GETBIT pings:2024-01-01-00:00 123
</span></span><span class="line hl"><span class="cl">1
</span></span><span class="line hl"><span class="cl">> GETBIT pings:2024-01-01-00:00 456
</span></span><span class="line hl"><span class="cl">0</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_bitmap_tutorial-stepping')" 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_bitmap_tutorial-stepping" name="bitmap_tutorial-stepping" 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_bitmap_tutorial-stepping" title="Open example">
Python
</label>
<div aria-labelledby="tab-bitmap_tutorial-stepping" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_bitmap_tutorial-stepping" 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 Bitmap doc pages:
</span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/bitmaps/
</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 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">setbit</span><span class="p">(</span><span class="s2">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="mi">123</span><span class="p">,</span> <span class="mi">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">res1</span><span class="p">)</span> <span class="c1"># >>> 0</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">getbit</span><span class="p">(</span><span class="s2">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="mi">123</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"># >>> 1</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">getbit</span><span class="p">(</span><span class="s2">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="mi">456</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"># >>> 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">r</span><span class="o">.</span><span class="n">setbit</span><span class="p">(</span><span class="s2">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="mi">123</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
</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">bitcount</span><span class="p">(</span><span class="s2">"pings:2024-01-01-00:00"</span><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"># >>> 1</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_bitmap_tutorial-stepping')" 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_bitmap_tutorial-stepping" 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_bitmap.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_bitmap_tutorial-stepping" name="bitmap_tutorial-stepping" 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_bitmap_tutorial-stepping" title="Open example">
Node.js
</label>
<div aria-labelledby="tab-bitmap_tutorial-stepping" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_bitmap_tutorial-stepping" 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">setBit</span><span class="p">(</span><span class="s2">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="mi">123</span><span class="p">,</span> <span class="mi">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">res1</span><span class="p">)</span> <span class="c1">// >>> 0
</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">getBit</span><span class="p">(</span><span class="s2">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="mi">123</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">// >>> 1
</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">getBit</span><span class="p">(</span><span class="s2">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="mi">456</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">// >>> 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">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">setBit</span><span class="p">(</span><span class="s2">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="mi">123</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
</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">bitCount</span><span class="p">(</span><span class="s2">"pings:2024-01-01-00:00"</span><span class="p">)</span>
</span></span><span class="line"><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">// >>> 1
</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_bitmap_tutorial-stepping')" 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_bitmap_tutorial-stepping" 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-bitmap.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_bitmap_tutorial-stepping" name="bitmap_tutorial-stepping" 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_bitmap_tutorial-stepping" title="Open example">
Java
</label>
<div aria-labelledby="tab-bitmap_tutorial-stepping" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_bitmap_tutorial-stepping" 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">org.junit.Assert</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.junit.Test</span><span class="o">;</span>
</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">BitMapsExample</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 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></span><span class="line hl"><span class="cl"> <span class="kt">boolean</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">setbit</span><span class="o">(</span><span class="s">"pings:2024-01-01-00:00"</span><span class="o">,</span> <span class="mi">123</span><span class="o">,</span> <span class="kc">true</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">// >>> false
</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">boolean</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">getbit</span><span class="o">(</span><span class="s">"pings:2024-01-01-00:00"</span><span class="o">,</span> <span class="mi">123</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">// >>> 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="kt">boolean</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">getbit</span><span class="o">(</span><span class="s">"pings:2024-01-01-00:00"</span><span class="o">,</span> <span class="mi">456</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">// >>> false
</span></span></span><span class="line"><span class="cl"><span class="c1"></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">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">bitcount</span><span class="o">(</span><span class="s">"pings:2024-01-01-00:00"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> 1
</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></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_bitmap_tutorial-stepping')" 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_bitmap_tutorial-stepping" 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/BitMapsExample.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_bitmap_tutorial-stepping" name="bitmap_tutorial-stepping" 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_bitmap_tutorial-stepping" title="Open example">
Go
</label>
<div aria-labelledby="tab-bitmap_tutorial-stepping" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_bitmap_tutorial-stepping" 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_ping</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">&</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">SetBit</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="mi">123</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 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">// >>> 0
</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">GetBit</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="mi">123</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">// >>> 1
</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">GetBit</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="mi">456</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">res3</span><span class="p">)</span> <span class="c1">// >>> 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_bitcount</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">&</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">BitCount</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"pings:2024-01-01-00:00"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">BitCount</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Start</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">End</span><span class="p">:</span> <span class="mi">456</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 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="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_bitmap_tutorial-stepping')" 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_bitmap_tutorial-stepping" 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/bitmap_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_bitmap_tutorial-stepping" name="bitmap_tutorial-stepping" 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_bitmap_tutorial-stepping" title="Open example">
C#
</label>
<div aria-labelledby="tab-bitmap_tutorial-stepping" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_bitmap_tutorial-stepping" 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></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">Bitmap_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">StringSetBit</span><span class="p">(</span><span class="s">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="m">123</span><span class="p">,</span> <span class="k">true</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">// >>> 0</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">StringGetBit</span><span class="p">(</span><span class="s">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="m">123</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">// >>> 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">StringGetBit</span><span class="p">(</span><span class="s">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="m">456</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">// >>> False</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'ping' 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">StringSetBit</span><span class="p">(</span><span class="s">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="m">123</span><span class="p">,</span> <span class="k">true</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringBitCount</span><span class="p">(</span><span class="s">"pings:2024-01-01-00:00"</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 1</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'bitcount' 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_bitmap_tutorial-stepping')" 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_bitmap_tutorial-stepping" 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/Bitmap_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="bit-operations">
Bit Operations
</h2>
<p>
Bit operations are divided into two groups: constant-time single bit
operations, like setting a bit to 1 or 0, or getting its value, and
operations on groups of bits, for example counting the number of set
bits in a given range of bits (e.g., population counting).
</p>
<p>
One of the biggest advantages of bitmaps is that they often provide
extreme space savings when storing information. For example in a system
where different users are represented by incremental user IDs, it is possible
to remember a single bit information (for example, knowing whether
a user wants to receive a newsletter) of 4 billion users using just 512 MB of memory.
</p>
<p>
The
<a href="/docs/latest/commands/setbit/">
<code>
SETBIT
</code>
</a>
command takes as its first argument the bit number, and as its second
argument the value to set the bit to, which is 1 or 0. The command
automatically enlarges the string if the addressed bit is outside the
current string length.
</p>
<p>
<a href="/docs/latest/commands/getbit/">
<code>
GETBIT
</code>
</a>
just returns the value of the bit at the specified index.
Out of range bits (addressing a bit that is outside the length of the string
stored into the target key) are always considered to be zero.
</p>
<p>
There are three commands operating on group of bits:
</p>
<ol>
<li>
<a href="/docs/latest/commands/bitop/">
<code>
BITOP
</code>
</a>
performs bit-wise operations between different strings. The provided operations are AND, OR, XOR and NOT.
</li>
<li>
<a href="/docs/latest/commands/bitcount/">
<code>
BITCOUNT
</code>
</a>
performs population counting, reporting the number of bits set to 1.
</li>
<li>
<a href="/docs/latest/commands/bitpos/">
<code>
BITPOS
</code>
</a>
finds the first bit having the specified value of 0 or 1.
</li>
</ol>
<p>
Both
<a href="/docs/latest/commands/bitpos/">
<code>
BITPOS
</code>
</a>
and
<a href="/docs/latest/commands/bitcount/">
<code>
BITCOUNT
</code>
</a>
are able to operate with byte ranges of the
string, instead of running for the whole length of the string. We can trivially see the number of bits that have been set in a bitmap.
</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="bitmap_tutorial-stepbitcount">
<input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_bitmap_tutorial-stepbitcount" name="bitmap_tutorial-stepbitcount" 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_bitmap_tutorial-stepbitcount" title="Open example">
>_ Redis CLI
</label>
<div aria-labelledby="tab-bitmap_tutorial-stepbitcount" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_bitmap_tutorial-stepbitcount" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">> BITCOUNT pings:2024-01-01-00:00
</span></span><span class="line hl"><span class="cl">(integer) 1</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_bitmap_tutorial-stepbitcount')" 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_bitmap_tutorial-stepbitcount" name="bitmap_tutorial-stepbitcount" 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_bitmap_tutorial-stepbitcount" title="Open example">
Python
</label>
<div aria-labelledby="tab-bitmap_tutorial-stepbitcount" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_bitmap_tutorial-stepbitcount" 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 Bitmap doc pages:
</span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/bitmaps/
</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">setbit</span><span class="p">(</span><span class="s2">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="mi">123</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">res1</span><span class="p">)</span> <span class="c1"># >>> 0</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">getbit</span><span class="p">(</span><span class="s2">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="mi">123</span><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"># >>> 1</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">getbit</span><span class="p">(</span><span class="s2">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="mi">456</span><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"># >>> 0</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">r</span><span class="o">.</span><span class="n">setbit</span><span class="p">(</span><span class="s2">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="mi">123</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
</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">bitcount</span><span class="p">(</span><span class="s2">"pings:2024-01-01-00:00"</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"># >>> 1</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_bitmap_tutorial-stepbitcount')" 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_bitmap_tutorial-stepbitcount" 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_bitmap.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_bitmap_tutorial-stepbitcount" name="bitmap_tutorial-stepbitcount" 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_bitmap_tutorial-stepbitcount" title="Open example">
Node.js
</label>
<div aria-labelledby="tab-bitmap_tutorial-stepbitcount" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_bitmap_tutorial-stepbitcount" 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">setBit</span><span class="p">(</span><span class="s2">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="mi">123</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">res1</span><span class="p">)</span> <span class="c1">// >>> 0
</span></span></span><span class="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">getBit</span><span class="p">(</span><span class="s2">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="mi">123</span><span class="p">)</span>
</span></span><span class="line"><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">// >>> 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">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">getBit</span><span class="p">(</span><span class="s2">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="mi">456</span><span class="p">)</span>
</span></span><span class="line"><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">// >>> 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 hl"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">setBit</span><span class="p">(</span><span class="s2">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="mi">123</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
</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">bitCount</span><span class="p">(</span><span class="s2">"pings:2024-01-01-00:00"</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">// >>> 1
</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_bitmap_tutorial-stepbitcount')" 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_bitmap_tutorial-stepbitcount" 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-bitmap.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_bitmap_tutorial-stepbitcount" name="bitmap_tutorial-stepbitcount" 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_bitmap_tutorial-stepbitcount" title="Open example">
Java
</label>
<div aria-labelledby="tab-bitmap_tutorial-stepbitcount" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_bitmap_tutorial-stepbitcount" 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">org.junit.Assert</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.junit.Test</span><span class="o">;</span>
</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">BitMapsExample</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 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></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">setbit</span><span class="o">(</span><span class="s">"pings:2024-01-01-00:00"</span><span class="o">,</span> <span class="mi">123</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> false
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">getbit</span><span class="o">(</span><span class="s">"pings:2024-01-01-00:00"</span><span class="o">,</span> <span class="mi">123</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> true
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">getbit</span><span class="o">(</span><span class="s">"pings:2024-01-01-00:00"</span><span class="o">,</span> <span class="mi">456</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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">// >>> false
</span></span></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="kt">long</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">bitcount</span><span class="o">(</span><span class="s">"pings:2024-01-01-00:00"</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">// >>> 1
</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></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_bitmap_tutorial-stepbitcount')" 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_bitmap_tutorial-stepbitcount" 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/BitMapsExample.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_bitmap_tutorial-stepbitcount" name="bitmap_tutorial-stepbitcount" 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_bitmap_tutorial-stepbitcount" title="Open example">
Go
</label>
<div aria-labelledby="tab-bitmap_tutorial-stepbitcount" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_bitmap_tutorial-stepbitcount" 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_ping</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">&</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">SetBit</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="mi">123</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">res1</span><span class="p">)</span> <span class="c1">// >>> 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">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">GetBit</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="mi">123</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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">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">GetBit</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="mi">456</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><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">// >>> 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_bitcount</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">&</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">BitCount</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"pings:2024-01-01-00:00"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">BitCount</span><span class="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">Start</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">End</span><span class="p">:</span> <span class="mi">456</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 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="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_bitmap_tutorial-stepbitcount')" 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_bitmap_tutorial-stepbitcount" 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/bitmap_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_bitmap_tutorial-stepbitcount" name="bitmap_tutorial-stepbitcount" 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_bitmap_tutorial-stepbitcount" title="Open example">
C#
</label>
<div aria-labelledby="tab-bitmap_tutorial-stepbitcount" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_bitmap_tutorial-stepbitcount" 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></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">Bitmap_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">StringSetBit</span><span class="p">(</span><span class="s">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="m">123</span><span class="p">,</span> <span class="k">true</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 0</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">StringGetBit</span><span class="p">(</span><span class="s">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="m">123</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> 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">StringGetBit</span><span class="p">(</span><span class="s">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="m">456</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> False</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'ping' 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">StringSetBit</span><span class="p">(</span><span class="s">"pings:2024-01-01-00:00"</span><span class="p">,</span> <span class="m">123</span><span class="p">,</span> <span class="k">true</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringBitCount</span><span class="p">(</span><span class="s">"pings:2024-01-01-00:00"</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">res5</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="c1">// Tests for 'bitcount' 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_bitmap_tutorial-stepbitcount')" 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_bitmap_tutorial-stepbitcount" 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/Bitmap_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 example imagine you want to know the longest streak of daily visits of
your web site users. You start counting days starting from zero, that is the
day you made your web site public, and set a bit with
<a href="/docs/latest/commands/setbit/">
<code>
SETBIT
</code>
</a>
every time
the user visits the web site. As a bit index you simply take the current unix
time, subtract the initial offset, and divide by the number of seconds in a day
(normally, 3600*24).
</p>
<p>
This way for each user you have a small string containing the visit
information for each day. With
<a href="/docs/latest/commands/bitcount/">
<code>
BITCOUNT
</code>
</a>
it is possible to easily get
the number of days a given user visited the web site, while with
a few
<a href="/docs/latest/commands/bitpos/">
<code>
BITPOS
</code>
</a>
calls, or simply fetching and analyzing the bitmap client-side,
it is possible to easily compute the longest streak.
</p>
<p>
Bitmaps are trivial to split into multiple keys, for example for
the sake of sharding the data set and because in general it is better to
avoid working with huge keys. To split a bitmap across different keys
instead of setting all the bits into a key, a trivial strategy is just
to store M bits per key and obtain the key name with
<code>
bit-number/M
</code>
and
the Nth bit to address inside the key with
<code>
bit-number MOD M
</code>
.
</p>
<h2 id="performance">
Performance
</h2>
<p>
<a href="/docs/latest/commands/setbit/">
<code>
SETBIT
</code>
</a>
and
<a href="/docs/latest/commands/getbit/">
<code>
GETBIT
</code>
</a>
are O(1).
<a href="/docs/latest/commands/bitop/">
<code>
BITOP
</code>
</a>
is O(n), where
<em>
n
</em>
is the length of the longest string in the comparison.
</p>
<h2 id="learn-more">
Learn more
</h2>
<ul>
<li>
<a href="https://www.youtube.com/watch?v=oj8LdJQjhJo">
Redis Bitmaps Explained
</a>
teaches you how to use bitmaps for map exploration in an online game.
</li>
<li>
<a href="https://university.redis.com/courses/ru101/">
Redis University's RU101
</a>
covers Redis bitmaps in detail.
</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/bitmaps/"/>
<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/users/refresh_jwt/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Refresh JWT requests
</h1>
<p class="text-lg -mt-5 mb-10">
Refresh JW token requests
</p>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="#post-refresh_jwt">
POST
</a>
</td>
<td>
<code>
/v1/users/refresh_jwt
</code>
</td>
<td>
Get a new authentication token
</td>
</tr>
</tbody>
</table>
<h2 id="post-refresh_jwt">
Get a new authentication token
</h2>
<pre><code>POST /v1/users/refresh_jwt
</code></pre>
<p>
Generate a new JSON Web Token (JWT) for authentication.
</p>
<p>
Takes a valid token and returns the new token generated by the request.
</p>
<h3 id="post-request">
Request
</h3>
<h4 id="example-http-request">
Example HTTP request
</h4>
<pre><code>POST /users/refresh_jwt
</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>
Authorization
</td>
<td>
JWT eyJ5bGciOiKIUzI1NiIsInR5cCI6IkpXVCJ9.
<br/>
<br/>
eyJpYXViOjE0NjU0NzU0ODYsInVpZFI1IjEiLCJ
<br/>
<br/>
leHAiOjE0NjU0Nz30OTZ9.2xYXumd1rDoE0e
<br/>
<br/>
dFzcLElMOHsshaqQk2HUNgdsUKxMU
</td>
<td>
Valid JSON Web Token (JWT)
</td>
</tr>
</tbody>
</table>
<h4 id="request-body">
Request body
</h4>
<table>
<thead>
<tr>
<th>
Field
</th>
<th>
Type
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
ttl
</td>
<td>
integer
</td>
<td>
Time to live - The amount of time in seconds the token will be valid (optional)
</td>
</tr>
</tbody>
</table>
<h3 id="post-response">
Response
</h3>
<p>
Returns a JSON object that contains the generated access token.
</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="nt">"access_token"</span><span class="p">:</span> <span class="s2">"eyJ5bGciOiKIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXViOjE0NjU0NzU0ODYsInVpZFI1IjEiLCJleHAiOjE0NjU0Nz30OTZ9.2xYXumd1rDoE0edFzcLElMOHsshaqQk2HUNgdsUKxMU"</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span></code></pre>
</div>
<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>
A new token is given.
</td>
</tr>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2">
401 Unauthorized
</a>
</td>
<td>
The token is invalid or password has expired.
</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/users/refresh_jwt/"/>
<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/redis-in-ai/.html | <section class="prose w-full py-12">
<h1>
Redis in AI agents, chatbots, and applications
</h1>
<p class="text-lg -mt-5 mb-10">
Integrate Redis into your AI agents, chatbots, and applications.
</p>
<p>
Integrate Redis into your projects to deliver fast, reliable, scalable AI-powered interactions for high-quality user experiences. Redis stores and indexes vector embeddings that semantically represent unstructured data.
Using vector search, Redis retrieves similar previously answered questions, reducing LLM inference costs and latency. Redis fetches recent and relevant portions of the chat history to provide context, improving the quality and accuracy of responses. Redis is ideal for RAG systems and AI agents requiring rapid data retrieval and generation.
</p>
<h2 id="benefits-of-integrating-redis-in-your-ai-agents-and-applications">
Benefits of integrating Redis in your AI agents and applications
</h2>
<ul>
<li>
Performance: Redis provides low-latency data access, crucial for real-time AI interactions.
</li>
<li>
Scalability: Redis can handle a large number of concurrent connections, making it suitable for high-traffic AI applications.
</li>
<li>
Caching: Redis efficiently caches responses and frequently accessed data, reducing the load on primary databases and improving response times.
</li>
<li>
Session Management: Redis in-memory data structures make it ideal for storing and managing session states in conversational AI applications.
</li>
<li>
Flexibility: Redis support for various data structures (strings, hashes, lists, sets) allows you to customize your AI solutions according to specific needs.
</li>
</ul>
<p>
<a href="/docs/latest/integrate/redisvl/">
RedisVL
</a>
is a versatile Python library with an integrated CLI, designed to enhance AI applications implemented using Redis.
</p>
<h2 id="use-cases-for-redis-in-ai-agents-chatbots-and-applications">
Use cases for Redis in AI agents, chatbots, and applications
</h2>
<p>
Refer to the following specific use cases for examples of Redis technology use cases in AI with tutorials and demo application code repositories.
</p>
<h3 id="ai-agent-performance-optimization">
AI agent performance optimization
</h3>
<p>
Advanced conversational interfaces integrate Redis for session persistence and caching to optimize the performance of conversational agents handling large volumes of interactions. See the
<a href="https://redis.io/learn/howtos/solutions/flowise/conversational-agent">
Flowise conversational agent with Redis
</a>
for a tutorial and demo application code.
</p>
<h3 id="chatbot-management">
Chatbot management
</h3>
<p>
Platforms for building, deploying, and managing chatbots use Redis for caching, session management, and as a message broker. Developers integrate Redis for state management and caching to enhance the responsiveness and scalability of their bots. See
<a href="https://redis.io/learn/howtos/solutions/vector/gen-ai-chatbot">
How to build a GenAI chatbot using LangChain and Redis
</a>
for a tutorial and demo application code.
</p>
<p>
AI-powered chatbot platforms designed for customer support automation use Redis for managing session states, caching data, and ensuring fast response times in customer interactions.
Customer engagement platforms that combine chatbots with human support use Redis for storing temporary data and ensuring fast access to frequently used information. See
<a href="https://redis.io/learn/howtos/solutions/vector/ai-qa-videos-langchain-redis-openai-google">
Building an AI-Powered Video Q&A Application with Redis and LangChain
</a>
for a tutorial and demo application code.
</p>
<h3 id="ml-frameworks-integration">
ML frameworks integration
</h3>
<p>
Machine learning frameworks for building AI assistants and chatbots can use Redis for handling message queuing and as a backend for tracking conversation states, ensuring real-time interaction and scalability. See
<a href="https://redis.io/learn/howtos/solutions/vector/image-summary-search">
Semantic Image Based Queries Using LangChain (OpenAI) and Redis
</a>
for a tutorial and demo application code. Register for the
<a href="https://redis.io/university/courses/ru402/">
Redis as a vector database course
</a>
to learn how Redis is well-integrated with LangChain, LlamaIndex, FeatureForm, Amazon Bedrock, and AzureOpenAI.
</p>
<h3 id="natural-language-processing">
Natural language processing
</h3>
<p>
Natural language understanding platforms for building conversational interfaces often use Redis for session management and caching responses to improve performance and reduce latency. See
<a href="https://redis.io/learn/howtos/solutions/streams/streaming-llm-output">
Streaming LLM Output Using Redis Streams
</a>
for a tutorial and demo application.
</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/get-started/redis-in-ai/"/>
<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/cf.count/.html | <section class="prose w-full py-12">
<h1 class="command-name">
CF.COUNT
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">CF.COUNT key 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 1.0.0
</a>
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(k), where k is the number of sub-filters
</dd>
</dl>
<p>
Returns an estimation of the number of times a given item was added to a cuckoo filter.
</p>
<p>
If you just want to check that a given item was added to a cuckoo filter, use
<a href="/docs/latest/commands/cf.exists/">
<code>
CF.EXISTS
</code>
</a>
.
</p>
<h2 id="required-arguments">
Required arguments
</h2>
<details open="">
<summary>
<code>
key
</code>
</summary>
<p>
is key name for a cuckoo filter.
</p>
</details>
<details open="">
<summary>
<code>
item
</code>
</summary>
<p>
is an item to check.
</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>
, where a positive value is an estimation of the number of times
<code>
item
</code>
was added to the filter. An overestimation is possible, but not an underestimation.
<code>
0
</code>
means that
<code>
key
</code>
does not exist or that
<code>
item
</code>
had not been added to the filter. See note in
<a href="/docs/latest/commands/cf.del/">
<code>
CF.DEL
</code>
</a>
.
</li>
<li>
[] on error (invalid arguments, wrong key type, etc.)
</li>
</ul>
<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> CF.INSERT cf ITEMS item1 item2 item2
</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> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1</span>
</span></span><span class="line"><span class="cl">3<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">redis> CF.COUNT cf item1
</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> CF.COUNT cf item2
</span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">2</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/cf.count/"/>
<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/configuration/clustering/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Clustering Redis Databases
</h1>
<p class="text-lg -mt-5 mb-10">
Redis Cloud uses clustering to manage very large databases (25 GB and larger). Here, you'll learn how to manage clustering and how to use hashing policies to control how data is managed.
</p>
<p>
For very large databases, Redis Cloud distributes database data to different cloud instances. For example:
</p>
<ul>
<li>
<p>
When data grows beyond the the RAM resources of a single server.
</p>
<p>
Multiple shards should be used when data grows to 25 GB (50 GB for Auto Tiering) to create multiple shards.
</p>
</li>
<li>
<p>
The operations performed against the database are CPU intensive enough to degrade performance.
</p>
<p>
Clustering distributes operational load, whether to instances on the same server or across multiple servers.
</p>
</li>
</ul>
<p>
This distribution is called
<em>
clustering
</em>
because it manages the way data is distributed throughout the cluster of nodes that support the database.
</p>
<h2 id="how-data-is-distributed">
How data is distributed
</h2>
<p>
A Redis Cloud cluster is a set of managed Redis processes and cloud instances,
with each process managing a subset of the database keyspace.
Clustering uses multiple cores and resources of multiple instances to overcome scaling challenges.
</p>
<p>
In a Redis Cloud cluster, the keyspace is partitioned into hash
slots. At any given time a hash slot resides on and is managed by a single
Redis server.
</p>
<p>
An instance that belongs to a cluster can manage multiple hash
slots. This division of the key space, known as
<em>
sharding
</em>
, is achieved by
hashing the key names, or parts of these (key hash tags), in order to
obtain the hash slot in which a key should reside.
</p>
<p>
Even when using multiple Redis processes, the use of a Redis
Enterprise Cloud cluster is nearly transparent to the application that
uses it. The cluster is accessible via a single endpoint that
automatically routes all operations to the relevant shards, without the
complexity of a cluster-aware Redis client. This allows applications to
benefit from using the cluster without performing any code changes, even
if they were not designed to use it beforehand.
</p>
<p>
When creating or editing a Redis database on Redis Cloud, the
system automatically calculates the number of shards needed based on
the database memory limit and required throughput.
</p>
<!-- DOC-439: Stubbing out for initial pass
<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 width="21" height="21" viewBox="0 0 21 21" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"/>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2"/>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2"/>
</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>For Redis Cloud Essentials, clustering is only available in the
"Pay-As-You-Go" subscription.</p>
<a href='/docs/latest/images/rc/clustering-subscription.png' sdata-lightbox="/images/rc/clustering-subscription.png">
<img src='/docs/latest/images/rc/clustering-subscription.png'
<pre><code> />
</code></pre>
</a>
</div>
</div>
-->
<h2 id="multikey-operations">
Multi-key operations
</h2>
<p>
Operations on multiple keys in a sharded Redis Cloud cluster
are supported, with the following limitations:
</p>
<ol>
<li>
<strong>
Multi-key commands:
</strong>
Redis offers several commands that accept
multiple keys as arguments. In a sharded setup, you can run multi-key commands
only if all the affected keys reside in the same slot (thus on the same shard).
This restriction applies to all mulit-key commands, including BITOP, BLPOP, BRPOP, BRPOPLPUSH, MSETNX,
RPOPLPUSH, SDIFF, SDIFFSTORE, SINTER, SINTERSTORE, SMOVE, SORT,
SUNION, XREAD, XREADGROUP, ZINTER, ZINTERSTORE, ZUNION, ZUNIONSTORE, ZDIFF, ZDIFFSTORE
</li>
<li>
<strong>
Geo commands:
</strong>
In GEORADIUS/GEORADIUSBYMEMBER/GEOSEARCHSTORE commands, the
STORE and STOREDIST options can only be used when all affected keys
reside in the same slot.
</li>
<li>
<strong>
Transactions:
</strong>
All operations within a WATCH/MULTI/EXEC block
should be performed on keys that are in the same slot.
</li>
<li>
<strong>
Lua scripts:
</strong>
All keys that are used by the script must reside in
the same slot and need to be provided as arguments to the
EVAL/EVALSHA commands (as per the Redis specification).
</li>
<li>
<strong>
Renaming/Copy keys:
</strong>
The use of the RENAME/RENAMENX/COPY commands is
allowed only when both the key's original name and its new name are
mapped to the same hash slot.
</li>
<li>
<strong>
Variadic commands
</strong>
: The use of (MGET, MSET, HMGET, HMSET, etc..)
and pipelining are supported with Redis Cloud cluster
like if it were a non-cluster DB.
</li>
</ol>
<h2 id="manage-the-hashing-policy">
Manage the hashing policy
</h2>
<p>
Redis defaults to the
<a href="#standard-hashing-policy">
standard hashing policy
</a>
.
The clustering configuration of a Redis Cloud instance can be changed.
However, hashing policy changes delete existing data
(FLUSHDB) before they're applied.
</p>
<p>
These changes include:
</p>
<ol>
<li>
Changing the hashing policy, either from standard to custom or vice versa.
</li>
<li>
Changing the order of custom hashing policy rules.
</li>
<li>
Adding rules before existing ones in the custom hashing policy.
</li>
<li>
Deleting rules from the custom hashing policy.
</li>
<li>
Disabling clustering for the database.
</li>
</ol>
<h3 id="standard-hashing-policy">
Standard hashing policy
</h3>
<p>
When using the standard hashing policy, a Redis Cloud cluster
behaves like a standard Redis cluster, and hashing is
performed as follows:
</p>
<ol>
<li>
Keys with a hashtag: a key's hashtag is any substring between '{'
and '}' in the key's name. That means that when a key's name
includes the pattern '{...}', the hashtag is used as input for the
hashing function. For example, the following key names have the same
hashtag and are mapped to the same slot: foo{bar},
{bar}baz & foo{bar}baz.
</li>
<li>
Keys without a hashtag: when a key doesn't contain the '{...}'
pattern, the entire key's name is used for hashing.
</li>
</ol>
<p>
You can use the '{...}' pattern to direct related keys to the same hash
slot, so that multi-key operations are supported on them. On the other
hand, not using a hashtag in the key's name results in a
(statistically) even distribution of keys across the keyspace's shards,
which improves resource utilization.
If your application does not perform multi-key operations, you don't
need to construct key names with hashtags.
</p>
<h3 id="custom-hashing-policy">
Custom hashing policy
</h3>
<p>
A Redis Cloud cluster can be configured to use a custom hashing
policy. A custom hashing policy is required when different keys need to
be kept together on the same shard to allow multi-key operations. Redis
Cloud's custom hashing policy is provided via a set of Perl
Compatible Regular Expressions (PCRE) rules that describe the dataset's
key name patterns.
</p>
<p>
To configure a custom hashing policy, enter regular expression (RegEx)
rules that identify the substring in the key's name - hashtag - on
which hashing will be done. The hashing tag is denoted in the RegEx by
the use of the `tag` named subpattern. Different keys that have the
same hashtag will be stored and managed in the same slot.
</p>
<p>
Once you enable the custom hashing policy, the Redis Cloud's
default RegEx rules that implement the standard hashing policy are:
</p>
<table>
<thead>
<tr>
<th>
RegEx Rule
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
.*{(?<tag>.*)}.*
</td>
<td>
Hashing is done on the substring between the curly braces.
</td>
</tr>
<tr>
<td>
(?<tag>.*)
</td>
<td>
The entire key's name is used for hashing.
</td>
</tr>
</tbody>
</table>
<p>
You can modify existing rules, add new ones, delete rules, or change
their order to suit your application's requirements.
</p>
<h3 id="custom-hashing-policy-notes-and-limitations">
Custom hashing policy notes and limitations
</h3>
<ol>
<li>
You can define up to 32 RegEx rules, each up to 256 characters.
</li>
<li>
RegEx rules are evaluated by their order.
</li>
<li>
The first rule matched is used; strive to place common key name
patterns at the beginning of the rule list.
</li>
<li>
Key names that do not match any of the RegEx rules trigger an
error.
</li>
<li>
The '.*(?<tag>)' RegEx rule forces keys into a single slot as the
hash key is always empty. When used, this should be the last
catch-all rule.
</li>
<li>
The following flag is enabled in our regular expression parser:
<ul>
<li>
<strong>
PCRE_ANCHORED:
</strong>
the pattern is constrained to match only at
the start of the string which is being searched.
</li>
</ul>
</li>
</ol>
<h2 id="dataset-size">
Dataset size
</h2>
<p>
The dataset size of a database is a part of the full memory limit for the database. The memory limit represents the maximum amount of memory for the database, which includes data values, keys, module data, and overhead for specific features. High availability features, such as replication and Active-Active, increase memory consumption, so in those cases your dataset size and memory limit will be different.
</p>
<p>
For Redis Cloud Essentials, the plan size refers to the full memory limit, not the dataset size. Both the total memory limit and dataset size are listed under
<strong>
Database details
</strong>
when you create an Essentials database.
</p>
<p>
For Redis Cloud Pro, you define your dataset size when you create the database, and we calculate your total memory limit based on the features you choose.
</p>
<p>
Here are some general guidelines:
</p>
<ul>
<li>
<p>
Memory limit represents an upper limit. You cannot store more data than the memory limit. Depending on your other selections, available memory for data may be less than expected.
</p>
</li>
<li>
<p>
<a href="/docs/latest/operate/rc/databases/configuration/high-availability/">
Replication
</a>
doubles memory consumption; that is, 512 MB of data requires at least 1 GB of memory limit when replication is enabled. This affects both Redis Cloud Pro and Redis Cloud Essentials. For example, if you subscribe to a 1 GB Essentials plan, Redis will allocate 512 MB for your dataset and the other 512 MB for replication.
</p>
</li>
<li>
<p>
<a href="/docs/latest/operate/rc/databases/configuration/active-active-redis/">
Active-Active
</a>
also doubles memory consumption and the effect is cumulative with replication's impact. Since Active-Active requires replication to be turned on, the memory limit impact can be as large as four times (4x) the original data size.
</p>
</li>
<li>
<p>
<a href="/docs/latest/operate/rc/databases/configuration/advanced-capabilities/">
Advanced capabilities
</a>
also consume memory. For search databases, consider index size when you size your database.
</p>
</li>
</ul>
<p>
Memory limits in Redis Cloud are subject to the same considerations as Redis Enterprise Software; to learn more, see
<a href="/docs/latest/operate/rs/databases/memory-performance/memory-limit/">
Database memory limits
</a>
.
</p>
<h2 id="throughput">
Throughput
</h2>
<p>
Throughput is the amount of operations a database can handle over a certain period of time. For Redis Cloud databases, throughput is defined in operations per second (ops/sec).
</p>
<p>
For a Redis Cloud Pro subscription, you define throughput for a database when you create it. For a Redis Cloud Essentials subscription, your maximum throughput depends on your plan.
</p>
<p>
We assume a typical workload that includes a different mix of commands and an average key and value size of 1KB. Therefore, your actual throughput may be higher or lower than the throughput you set when you create your database. The following properties can affect your database's throughput:
</p>
<ul>
<li>
<strong>
Command complexity
</strong>
: O(N) and O(log(N)) commands will take more time than O(1) commands, and will affect throughput accordingly.
</li>
<li>
<strong>
Key and value sizing
</strong>
: If your database's keys and values are very large, your actual throughput may be lower than expected. If the keys and values are smaller than the typical workload, the actual throughput might be higher than expected.
</li>
<li>
<strong>
Replication
</strong>
: Using
<a href="/docs/latest/operate/rc/databases/configuration/high-availability/">
multi-zone replication
</a>
affects throughput as each write operation is executed asynchronously in each zone.
</li>
<li>
<strong>
Security
</strong>
: Some security options, such as
<a href="/docs/latest/operate/rc/security/database-security/tls-ssl/">
transport layer security
</a>
, may affect throughput.
</li>
<li>
<strong>
Number of client connections
</strong>
: The number of client connections affects throughput. Increasing or decreasing the number of client connections can result in higher or lower throughput.
</li>
</ul>
<h2 id="oss-cluster-api">
Cluster API
</h2>
<p>
OSS Cluster API reduces access times and latency with near-linear scalability.
The OSS Cluster API provides a simple mechanism for Redis clients to know the cluster topology.
</p>
<p>
Clients must first connect to the master node to get the cluster topology,
and then they connect directly to the Redis proxy on each node that hosts a master shard.
</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>
You must use a client that supports the cluster API to connect to a database
that has the cluster API enabled.
</div>
</div>
<p>
The Cluster API is only supported on Redis Cloud Pro databases. You can enable it in the Scalability section of the configuration screen.
</p>
<p>
The Redis Cluster API is supported only when a database uses the
<a href="#standard-hashing-policy">
standard hashing policy
</a>
and does not use Search and Query or Time Series advanced capabilities.
</p>
<p>
Review
<a href="/docs/latest/operate/rs/clusters/optimize/oss-cluster-api/">
Redis Cluster API architecture
</a>
to determine if you should enable this feature for your database.
</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/databases/configuration/clustering/"/>
<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/gears-v1/jvm/classes/gearsfuture/seterror/.html | <section class="prose w-full py-12 max-w-none">
<h1>
SetError
</h1>
<p class="text-lg -mt-5 mb-10">
Sets an error message.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kd">public</span> <span class="kt">void</span> <span class="n">setError</span><span class="err">β</span><span class="o">(</span><span class="n">java</span><span class="o">.</span><span class="na">lang</span><span class="o">.</span><span class="na">String</span> <span class="n">error</span><span class="o">)</span>
</span></span><span class="line"><span class="cl"> <span class="kd">throws</span> <span class="n">java</span><span class="o">.</span><span class="na">lang</span><span class="o">.</span><span class="na">Exception</span>
</span></span></code></pre>
</div>
<p>
Sets an error message for an asynchronous computation.
</p>
<h2 id="parameters">
Parameters
</h2>
<table>
<thead>
<tr>
<th>
Name
</th>
<th>
Type
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
error
</td>
<td>
string
</td>
<td>
An error message
</td>
</tr>
</tbody>
</table>
<h2 id="returns">
Returns
</h2>
<p>
None
</p>
<h2 id="example">
Example
</h2>
<div class="highlight">
<pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="n">GearsFuture</span><span class="o"><</span><span class="n">Boolean</span><span class="o">></span> <span class="n">f</span> <span class="o">=</span> <span class="k">new</span> <span class="n">GearsFuture</span><span class="o"><</span><span class="n">Boolean</span><span class="o">>();</span>
</span></span><span class="line"><span class="cl"><span class="k">try</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">f</span><span class="o">.</span><span class="na">setError</span><span class="o">(</span><span class="s">"An error has occurred during asyncForeach"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"><span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">Exception</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">e</span><span class="o">.</span><span class="na">printStackTrace</span><span class="o">();</span>
</span></span><span class="line"><span class="cl"><span class="o">}</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/oss_and_stack/stack-with-enterprise/gears-v1/jvm/classes/gearsfuture/seterror/"/>
<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/management/optimization/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Optimizing Redis
</h1>
<p class="text-lg -mt-5 mb-10">
Benchmarking, profiling, and optimizations for memory and latency
</p>
<nav>
<a href="/docs/latest/operate/oss_and_stack/management/optimization/benchmarks/">
Redis benchmark
</a>
<p>
Use the redis-benchmark utility on a Redis server
</p>
<a href="/docs/latest/operate/oss_and_stack/management/optimization/cpu-profiling/">
Redis CPU profiling
</a>
<p>
Performance engineering guide for on-CPU profiling and tracing
</p>
<a href="/docs/latest/operate/oss_and_stack/management/optimization/latency/">
Diagnosing latency issues
</a>
<p>
Finding the causes of slow responses
</p>
<a href="/docs/latest/operate/oss_and_stack/management/optimization/latency-monitor/">
Redis latency monitoring
</a>
<p>
Discovering slow server events in Redis
</p>
<a href="/docs/latest/operate/oss_and_stack/management/optimization/memory-optimization/">
Memory optimization
</a>
<p>
Strategies for optimizing memory usage in Redis
</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/management/optimization/"/>
<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/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Redis Enterprise Software
</h1>
<p class="text-lg -mt-5 mb-10">
The self-managed, enterprise-grade version of Redis.
</p>
<p>
<a href="https://redis.io/enterprise/">
Redis Enterprise
</a>
is a self-managed, enterprise-grade version of Redis.
</p>
<p>
With Redis Enterprise, you get many enterprise-grade capabilities, including:
</p>
<ul>
<li>
Linear scalability
</li>
<li>
High availability, backups, and recovery
</li>
<li>
Predictable performance
</li>
<li>
24/7 support
</li>
</ul>
<p>
You can run self-managed Redis Enterprise Software in an on-premises data center or on your preferred cloud platform.
</p>
<p>
If you prefer a fully managed Redis database-as-a-service, available on major public cloud services, consider setting up a
<a href="/docs/latest/operate/rc/">
Redis Cloud
</a>
subscription. You can
<a href="https://redis.io/try-free/">
try Redis Cloud
</a>
for free.
</p>
<h2 id="get-started">
Get started
</h2>
<p>
Build a small-scale cluster with the Redis Enterprise Software container image.
</p>
<ul>
<li>
<a href="/docs/latest/operate/rs/7.4/installing-upgrading/quickstarts/redis-enterprise-software-quickstart/">
Linux quickstart
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/7.4/installing-upgrading/quickstarts/docker-quickstart/">
Docker quickstart
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/7.4/databases/active-active/get-started/">
Get started with Active-Active
</a>
</li>
</ul>
<h2 id="install--setup">
Install & setup
</h2>
<p>
<a href="/docs/latest/operate/rs/7.4/installing-upgrading/">
Install & set up
</a>
a Redis Enterprise Software cluster.
</p>
<ul>
<li>
<a href="/docs/latest/operate/rs/7.4/networking/">
Networking
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/7.4/clusters/new-cluster-setup/">
Set up
</a>
&
<a href="/docs/latest/operate/rs/7.4/clusters/configure/">
configure
</a>
a
<a href="/docs/latest/operate/rs/7.4/clusters/">
cluster
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/7.4/release-notes/">
Release notes
</a>
</li>
</ul>
<h2 id="databases">
Databases
</h2>
<p>
Create and manage a
<a href="/docs/latest/operate/rs/7.4/databases/">
Redis database
</a>
on a cluster.
</p>
<ul>
<li>
<a href="/docs/latest/operate/rs/7.4/databases/create/">
Create a Redis Enterprise Software database
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/7.4/databases/configure/">
Configure database
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/7.4/databases/active-active/create/">
Create Active-Active database
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/7.4/databases/active-active/manage/">
Edit Active-Active database
</a>
</li>
</ul>
<h2 id="security">
Security
</h2>
<p>
<a href="/docs/latest/operate/rs/7.4/security/">
Manage secure connections
</a>
to the cluster and databases.
</p>
<ul>
<li>
<a href="/docs/latest/operate/rs/7.4/security/access-control/">
Access control
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/7.4/security/access-control/manage-users/">
Users
</a>
&
<a href="/docs/latest/operate/rs/7.4/security/access-control/">
roles
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/7.4/security/certificates/">
Certificates
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/7.4/security/encryption/tls/">
TLS
</a>
&
<a href="/docs/latest/operate/rs/7.4/security/encryption/">
Encryption
</a>
</li>
</ul>
<h2 id="reference">
Reference
</h2>
<p>
Use command-line utilities and the REST API to manage the cluster and databases.
</p>
<ul>
<li>
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/rladmin/">
rladmin
</a>
,
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/crdb-cli/">
crdb-cli
</a>
, &
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/">
other utilities
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/7.4/references/rest-api/">
REST API reference
</a>
&
<a href="/docs/latest/operate/rs/7.4/references/rest-api/quick-start/">
examples
</a>
</li>
<li>
<a href="/docs/latest/commands/">
Redis commands
</a>
</li>
</ul>
<h2 id="related-info">
Related info
</h2>
<ul>
<li>
<a href="/docs/latest/operate/rc/">
Redis Cloud
</a>
</li>
<li>
<a href="/docs/latest/operate/oss_and_stack/">
Redis Community Edition
</a>
</li>
<li>
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/">
Redis Stack
</a>
</li>
<li>
<a href="/docs/latest/glossary/">
Glossary
</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/"/>
<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/reference/gopher/.html | <section class="prose w-full py-12">
<h1>
Redis and the Gopher protocol
</h1>
<p class="text-lg -mt-5 mb-10">
The Redis Gopher protocol implementation
</p>
<p>
** Note: Support for Gopher was removed in Redis 7.0 **
</p>
<p>
Redis contains an implementation of the Gopher protocol, as specified in
the
<a href="https://www.ietf.org/rfc/rfc1436.txt">
RFC 1436
</a>
.
</p>
<p>
The Gopher protocol was very popular in the late '90s. It is an alternative
to the web, and the implementation both server and client side is so simple
that the Redis server has just 100 lines of code in order to implement this
support.
</p>
<p>
What do you do with Gopher nowadays? Well Gopher never
<em>
really
</em>
died, and
lately there is a movement in order for the Gopher more hierarchical content
composed of just plain text documents to be resurrected. Some want a simpler
internet, others believe that the mainstream internet became too much
controlled, and it's cool to create an alternative space for people that
want a bit of fresh air.
</p>
<p>
Anyway, for the 10th birthday of the Redis, we gave it the Gopher protocol
as a gift.
</p>
<h2 id="how-it-works">
How it works
</h2>
<p>
The Redis Gopher support uses the inline protocol of Redis, and specifically
two kind of inline requests that were anyway illegal: an empty request
or any request that starts with "/" (there are no Redis commands starting
with such a slash). Normal RESP2/RESP3 requests are completely out of the
path of the Gopher protocol implementation and are served as usually as well.
</p>
<p>
If you open a connection to Redis when Gopher is enabled and send it
a string like "/foo", if there is a key named "/foo" it is served via the
Gopher protocol.
</p>
<p>
In order to create a real Gopher "hole" (the name of a Gopher site in Gopher
talking), you likely need a script such as the one in
<a href="https://github.com/antirez/gopher2redis">
https://github.com/antirez/gopher2redis
</a>
.
</p>
<h2 id="security-warning">
SECURITY WARNING
</h2>
<p>
If you plan to put Redis on the internet in a publicly accessible address
to server Gopher pages
<strong>
make sure to set a password
</strong>
to the instance.
Once a password is set:
</p>
<ol>
<li>
The Gopher server (when enabled, not by default) will kill serve content via Gopher.
</li>
<li>
However other commands cannot be called before the client will authenticate.
</li>
</ol>
<p>
So use the
<code>
requirepass
</code>
option to protect your instance.
</p>
<p>
To enable Gopher support use the following configuration line.
</p>
<pre><code>gopher-enabled yes
</code></pre>
<p>
Accessing keys that are not strings or do not exit will generate
an error in Gopher protocol format.
</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/reference/gopher/"/>
<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/reference/cli/redis-di-config-rdi/.html | <section class="prose w-full py-12">
<h1>
redis-di config-rdi
</h1>
<p class="text-lg -mt-5 mb-10">
Configures RDI DB connection credentials
</p>
<h2 id="usage">
Usage
</h2>
<pre tabindex="0"><code>Usage: redis-di config-rdi [OPTIONS]
</code></pre>
<h2 id="options">
Options
</h2>
<ul>
<li>
<p>
<code>
log_level
</code>
:
</p>
<ul>
<li>
Type: Choice(['DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL'])
</li>
<li>
Default:
<code>
info
</code>
</li>
<li>
Usage:
<code>
--log-level -l
</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 RDI Database
</p>
</li>
<li>
<p>
<code>
rdi_port
</code>
(REQUIRED):
</p>
<ul>
<li>
Type: <IntRange 1<=x<=65535>
</li>
<li>
Default:
<code>
none
</code>
</li>
<li>
Usage:
<code>
--rdi-port
</code>
</li>
</ul>
<p>
Port of RDI Database
</p>
</li>
<li>
<p>
<code>
rdi_user
</code>
:
</p>
<ul>
<li>
Type: STRING
</li>
<li>
Default:
<code>
none
</code>
</li>
<li>
Usage:
<code>
--rdi-user
</code>
</li>
</ul>
<p>
RDI Database Username
</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>
RDI 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 config-rdi [OPTIONS]
Configures RDI db connection credentials
Options:
-l, --log-level [DEBUG|INFO|WARN|ERROR|CRITICAL]
[default: INFO]
--rdi-host TEXT Host/IP of RDI Database [required]
--rdi-port INTEGER RANGE Port of RDI Database [1<=x<=65535;
required]
--rdi-user TEXT RDI Database Username
--rdi-password TEXT RDI 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/redis-data-integration/reference/cli/redis-di-config-rdi/"/>
<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/crdb/health_report/.html | <section class="prose w-full py-12 max-w-none">
<h1>
CRDB health report object
</h1>
<p class="text-lg -mt-5 mb-10">
An object that represents an Active-Active database health report.
</p>
<p>
An object that represents an Active-Active database health report.
</p>
<table>
<thead>
<tr>
<th>
Name
</th>
<th>
Type/Value
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
active_config_version
</td>
<td>
integer
</td>
<td>
Active configuration version
</td>
</tr>
<tr>
<td>
cluster_name
</td>
<td>
string
</td>
<td>
Name of local Active-Active cluster
</td>
</tr>
<tr>
<td>
configurations
</td>
<td>
array of
<a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/crdb/health_report/health_report_configuration/">
health_report_configuration
</a>
objects
</td>
<td>
Stored database configurations
</td>
</tr>
<tr>
<td>
connection_error
</td>
<td>
string
</td>
<td>
Error string if remote cluster is not available
</td>
</tr>
<tr>
<td>
connections
</td>
<td>
<pre><code>
[{
"name": string,
"replication_links": [
{
"link_uid": "bdb_uid:replica_uid",
"status": "up | down"
} ],
"status": string
}, ...] </code></pre>
</td>
<td>
Connections to other clusters and their statuses. A replication link's
<code>
bdb_uid
</code>
is the unique ID of a local database instance (
<a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/bdb/">
bdb
</a>
) in the current cluster. The
<code>
replica_uid
</code>
is the unique ID of the database's remote replica, located in the connected cluster.
</td>
</tr>
<tr>
<td>
name
</td>
<td>
string
</td>
<td>
Name of the Active-Active database
</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/crdb/health_report/"/>
<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> 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/oss_and_stack/stack-with-enterprise/json/commands/.html | <section class="prose w-full py-12 max-w-none">
<h1>
JSON commands
</h1>
<p class="text-lg -mt-5 mb-10">
Lists JSON commands and provides links to the command reference pages.
</p>
<p>
The following table lists JSON 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
<br/>
Enterprise
</th>
<th style="text-align:left">
Redis
<br/>
Cloud
</th>
<th style="text-align:left">
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/json.arrappend">
JSON.ARRAPPEND
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
<nobr>
β
Flexible & Annual
</nobr>
</span>
<br/>
<span title="Supported">
β
Free & Fixed
</span>
</td>
<td style="text-align:left">
Appends an element to a JSON array.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/json.arrindex">
JSON.ARRINDEX
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Flexible & Annual
</span>
<br/>
<span title="Supported">
β
Free & Fixed
</span>
</td>
<td style="text-align:left">
Returns the index of a value's first occurrence in a JSON array.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/json.arrinsert">
JSON.ARRINSERT
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Flexible & Annual
</span>
<br/>
<span title="Supported">
β
Free & Fixed
</span>
</td>
<td style="text-align:left">
Inserts JSON values into a JSON array before the given index.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/json.arrlen">
JSON.ARRLEN
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Flexible & Annual
</span>
<br/>
<span title="Supported">
β
Free & Fixed
</span>
</td>
<td style="text-align:left">
Returns the length of a JSON array.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/json.arrpop">
JSON.ARRPOP
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Flexible & Annual
</span>
<br/>
<span title="Supported">
β
Free & Fixed
</span>
</td>
<td style="text-align:left">
Removes and returns an element located at the index in the JSON array.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/json.arrtrim">
JSON.ARRTRIM
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Flexible & Annual
</span>
<br/>
<span title="Supported">
β
Free & Fixed
</span>
</td>
<td style="text-align:left">
Trims a JSON array so that it contains only the specified inclusive range of elements.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/json.clear">
JSON.CLEAR
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Flexible & Annual
</span>
<br/>
<span title="Supported">
β
Free & Fixed
</span>
</td>
<td style="text-align:left">
Clears container values (arrays/objects) and sets numeric values to 0.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/json.debug">
JSON.DEBUG
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Flexible & Annual
</span>
<br/>
<span title="Supported">
β
Free & Fixed
</span>
</td>
<td style="text-align:left">
Debugging container command.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/json.debug-help">
JSON.DEBUG HELP
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Flexible & Annual
</span>
<br/>
<span title="Supported">
β
Free & Fixed
</span>
</td>
<td style="text-align:left">
Returns helpful information about the
<a href="/docs/latest/commands/json.debug">
JSON.DEBUG
</a>
command.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/json.debug-memory/">
JSON.DEBUG MEMORY
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Flexible & Annual
</span>
<br/>
<span title="Supported">
β
Free & Fixed
</span>
</td>
<td style="text-align:left">
Reports a JSON element's memory usage in bytes.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/json.del">
JSON.DEL
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Flexible & Annual
</span>
<br/>
<span title="Supported">
β
Free & Fixed
</span>
</td>
<td style="text-align:left">
Removes a JSON element.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/json.forget">
JSON.FORGET
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Flexible & Annual
</span>
<br/>
<span title="Supported">
β
Free & Fixed
</span>
</td>
<td style="text-align:left">
Removes a JSON element, the same as
<a href="/docs/latest/commands/json.del">
JSON.DEL
</a>
.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/json.get">
JSON.GET
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Flexible & Annual
</span>
<br/>
<span title="Supported">
β
Free & Fixed
</span>
</td>
<td style="text-align:left">
Returns the value of an element in JSON-serialized form.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/json.mget">
JSON.MGET
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Flexible & Annual
</span>
<br/>
<span title="Supported">
β
Free & Fixed
</span>
</td>
<td style="text-align:left">
Returns the values of multiple elements.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/json.numincrby">
JSON.NUMINCRBY
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Flexible & Annual
</span>
<br/>
<span title="Supported">
β
Free & Fixed
</span>
</td>
<td style="text-align:left">
Increments the number stored at path by the specified number.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/json.nummultby">
JSON.NUMMULTBY
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Flexible & Annual
</span>
<br/>
<span title="Supported">
β
Free & Fixed
</span>
</td>
<td style="text-align:left">
Multiplies the number stored at path by the specified number. (deprecated as of RedisJSON v2.0)
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/json.objkeys">
JSON.OBJKEYS
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Flexible & Annual
</span>
<br/>
<span title="Supported">
β
Free & Fixed
</span>
</td>
<td style="text-align:left">
Returns the keys contained in the specified JSON object.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/json.objlen">
JSON.OBJLEN
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Flexible & Annual
</span>
<br/>
<span title="Supported">
β
Free & Fixed
</span>
</td>
<td style="text-align:left">
Returns the number of keys in the specified JSON object.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/json.resp">
JSON.RESP
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Flexible & Annual
</span>
<br/>
<span title="Supported">
β
Free & Fixed
</span>
</td>
<td style="text-align:left">
Returns a JSON element in
<a href="/docs/latest/develop/reference/protocol-spec/">
Redis Serialization Protocol (RESP)
</a>
format.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/json.set">
JSON.SET
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Flexible & Annual
</span>
<br/>
<span title="Supported">
β
Free & Fixed
</span>
</td>
<td style="text-align:left">
Sets the value of a JSON element.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/json.strappend">
JSON.STRAPPEND
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Flexible & Annual
</span>
<br/>
<span title="Supported">
β
Free & Fixed
</span>
</td>
<td style="text-align:left">
Appends the given string to the specified key's existing strings.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/json.strlen">
JSON.STRLEN
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Flexible & Annual
</span>
<br/>
<span title="Supported">
β
Free & Fixed
</span>
</td>
<td style="text-align:left">
Returns the length of a string.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/json.toggle">
JSON.TOGGLE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Flexible & Annual
</span>
<br/>
<span title="Supported">
β
Free & Fixed
</span>
</td>
<td style="text-align:left">
If the boolean is
<code>
true
</code>
, changes it to
<code>
false
</code>
. If the boolean is
<code>
false
</code>
, changes it to
<code>
true
</code>
.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/json.type">
JSON.TYPE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Flexible & Annual
</span>
<br/>
<span title="Supported">
β
Free & Fixed
</span>
</td>
<td style="text-align:left">
Returns a JSON element's type.
</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/oss_and_stack/stack-with-enterprise/json/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/operate/rs/7.4/references/rest-api/objects/redis_acl/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Redis ACL object
</h1>
<p class="text-lg -mt-5 mb-10">
An object that represents a Redis access control list (ACL)
</p>
<p>
An API object that represents a Redis
<a href="/docs/latest/operate/rs/7.4/security/access-control/create-db-roles/">
access control list (ACL)
</a>
</p>
<table>
<thead>
<tr>
<th>
Name
</th>
<th>
Type/Value
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
uid
</td>
<td>
integer
</td>
<td>
Object's unique ID
</td>
</tr>
<tr>
<td>
account_id
</td>
<td>
integer
</td>
<td>
SM account ID
</td>
</tr>
<tr>
<td>
acl
</td>
<td>
string
</td>
<td>
Redis ACL's string
</td>
</tr>
<tr>
<td>
action_uid
</td>
<td>
string
</td>
<td>
Action UID. If it exists, progress can be tracked by the
<code>
GET
</code>
<code>
/actions/{uid}
</code>
API (read-only)
</td>
</tr>
<tr>
<td>
name
</td>
<td>
string
</td>
<td>
Redis ACL's name
</td>
</tr>
<tr>
<td>
min_version
</td>
<td>
string
</td>
<td>
Minimum database version that supports this ACL. Read only
</td>
</tr>
<tr>
<td>
max_version
</td>
<td>
string
</td>
<td>
Maximum database version that supports this ACL. Read only
</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/redis_acl/"/>
<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/connect/clients/dotnet/.html | <section class="prose w-full py-12 max-w-none">
<h1>
NRedisStack guide (C#/.NET)
</h1>
<p class="text-lg -mt-5 mb-10">
Connect your .NET application to a Redis database
</p>
<p>
<a href="https://github.com/redis/NRedisStack">
NRedisStack
</a>
is the .NET client for Redis.
The sections below explain how to install
<code>
NRedisStack
</code>
and connect your application
to a Redis database.
</p>
<p>
<code>
NRedisStack
</code>
requires a running Redis or
<a href="/docs/latest/operate/oss_and_stack/install/install-stack/">
Redis Stack
</a>
server. See
<a href="/docs/latest/operate/oss_and_stack/install/">
Getting started
</a>
for Redis installation instructions.
</p>
<p>
You can also access Redis with an object-mapping client interface. See
<a href="/docs/latest/integrate/redisom-for-net/">
Redis OM for .NET
</a>
for more information.
</p>
<h2 id="install">
Install
</h2>
<p>
Using the
<code>
dotnet
</code>
CLI, run:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">dotnet add package NRedisStack
</span></span></code></pre>
</div>
<h2 id="connect-and-test">
Connect and test
</h2>
<p>
Connect to localhost on port 6379.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-csharp" data-lang="csharp"><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">StackExchange.Redis</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="c1">//...</span>
</span></span><span class="line"><span class="cl"><span class="n">ConnectionMultiplexer</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"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="n">IDatabase</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></code></pre>
</div>
<p>
You can test the connection by storing and retrieving a simple string.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-csharp" data-lang="csharp"><span class="line"><span class="cl"><span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"foo"</span><span class="p">,</span> <span class="s">"bar"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</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">"foo"</span><span class="p">));</span> <span class="c1">// prints bar</span>
</span></span></code></pre>
</div>
<p>
Store and retrieve a HashMap.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-csharp" data-lang="csharp"><span class="line"><span class="cl"><span class="kt">var</span> <span class="n">hash</span> <span class="p">=</span> <span class="k">new</span> <span class="n">HashEntry</span><span class="p">[]</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">HashEntry</span><span class="p">(</span><span class="s">"name"</span><span class="p">,</span> <span class="s">"John"</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">HashEntry</span><span class="p">(</span><span class="s">"surname"</span><span class="p">,</span> <span class="s">"Smith"</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">HashEntry</span><span class="p">(</span><span class="s">"company"</span><span class="p">,</span> <span class="s">"Redis"</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">HashEntry</span><span class="p">(</span><span class="s">"age"</span><span class="p">,</span> <span class="s">"29"</span><span class="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">db</span><span class="p">.</span><span class="n">HashSet</span><span class="p">(</span><span class="s">"user-session:123"</span><span class="p">,</span> <span class="n">hash</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kt">var</span> <span class="n">hashFields</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">HashGetAll</span><span class="p">(</span><span class="s">"user-session:123"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">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">hashFields</span><span class="p">));</span>
</span></span><span class="line"><span class="cl"><span class="c1">// Prints: </span>
</span></span><span class="line"><span class="cl"><span class="c1">// name: John; surname: Smith; company: Redis; age: 29</span>
</span></span></code></pre>
</div>
<h2 id="redis-stack-modules">
Redis Stack modules
</h2>
<p>
To access Redis Stack capabilities, use the appropriate interface like this:
</p>
<pre tabindex="0"><code>IBloomCommands bf = db.BF();
ICuckooCommands cf = db.CF();
ICmsCommands cms = db.CMS();
IGraphCommands graph = db.GRAPH();
ITopKCommands topk = db.TOPK();
ITdigestCommands tdigest = db.TDIGEST();
ISearchCommands ft = db.FT();
IJsonCommands json = db.JSON();
ITimeSeriesCommands ts = db.TS();
</code></pre>
<h2 id="more-information">
More information
</h2>
<p>
See the other pages in this section for more information and examples.
</p>
<nav>
<a href="/docs/latest/develop/clients/dotnet/connect/">
Connect to the server
</a>
<p>
Connect your .NET application to a Redis database
</p>
<a href="/docs/latest/develop/clients/dotnet/queryjson/">
Example - Index and query JSON documents
</a>
<p>
Learn how to use the Redis query engine with JSON
</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/develop/clients/dotnet/"/>
<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-set-secret/.html | <section class="prose w-full py-12 max-w-none">
<h1>
redis-di set-secret
</h1>
<p class="text-lg -mt-5 mb-10">
Writes a secret to Redis secret store
</p>
<h2 id="usage">
Usage
</h2>
<pre tabindex="0"><code>Usage: redis-di set-secret [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>
cluster_host
</code>
(REQUIRED):
</p>
<ul>
<li>
Type: STRING
</li>
<li>
Default:
<code>
none
</code>
</li>
<li>
Usage:
<code>
--cluster-host
</code>
</li>
</ul>
<p>
Host/IP of Redis Enterprise Cluster (service name in case of k8s)
</p>
</li>
<li>
<p>
<code>
cluster_api_port
</code>
(REQUIRED):
</p>
<ul>
<li>
Type: <IntRange 1000<=x<=65535>
</li>
<li>
Default:
<code>
9443
</code>
</li>
<li>
Usage:
<code>
--cluster-api-port
</code>
</li>
</ul>
<p>
API Port of Redis Enterprise Cluster
</p>
</li>
<li>
<p>
<code>
cluster_user
</code>
(REQUIRED):
</p>
<ul>
<li>
Type: STRING
</li>
<li>
Default:
<code>
none
</code>
</li>
<li>
Usage:
<code>
--cluster-user
</code>
</li>
</ul>
<p>
Redis Enterprise Cluster username with either DB Member, Cluster Member or Cluster Admin roles
</p>
</li>
<li>
<p>
<code>
cluster_password
</code>
:
</p>
<ul>
<li>
Type: STRING
</li>
<li>
Default:
<code>
none
</code>
</li>
<li>
Usage:
<code>
--cluster-password
</code>
</li>
</ul>
<p>
Redis Enterprise Cluster Password
</p>
</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: <IntRange 1000<=x<=65535>
</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>
secret_name
</code>
(REQUIRED):
</p>
<ul>
<li>
Type: STRING
</li>
<li>
Default:
<code>
none
</code>
</li>
<li>
Usage:
<code>
--secret-name
</code>
</li>
</ul>
<p>
The name of the secret
</p>
</li>
<li>
<p>
<code>
secret_value
</code>
(REQUIRED):
</p>
<ul>
<li>
Type: STRING
</li>
<li>
Default:
<code>
none
</code>
</li>
<li>
Usage:
<code>
--secret-value
</code>
</li>
</ul>
<p>
The value of the secret
</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 set-secret [OPTIONS]
Writes a secret to Redis secret store
Options:
-log-level, --loglevel [DEBUG|INFO|WARN|ERROR|CRITICAL]
[default: INFO]
--cluster-host TEXT Host/IP of Redis Enterprise Cluster (service
name in case of k8s) [required]
--cluster-api-port INTEGER RANGE
API Port of Redis Enterprise Cluster
[default: 9443; 1000<=x<=65535; required]
--cluster-user TEXT Redis Enterprise Cluster username with
either DB Member, Cluster Member or Cluster
Admin roles [required]
--cluster-password TEXT Redis Enterprise Cluster Password
--rdi-host TEXT Host/IP of Write-behind Database [required]
--rdi-port INTEGER RANGE Port of Write-behind Database [1000<=x<=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
--secret-name TEXT The name of the secret [required]
--secret-value TEXT The value of the secret [required]
--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-set-secret/"/>
<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/hpexpireat/.html | <section class="prose w-full py-12">
<h1 class="command-name">
HPEXPIREAT
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">HPEXPIREAT key unix-time-milliseconds [NX | XX | GT | LT]
FIELDS numfields field [field ...]</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.4.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 arguments to the command
</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>
@hash
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@fast
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
<code>
HPEXPIREAT
</code>
has the same effect and semantics as
<a href="/docs/latest/commands/hexpireat/">
<code>
HEXPIREAT
</code>
</a>
, but the Unix time at
which the field will expire is specified in milliseconds since Unix epoch instead of seconds.
</p>
<h2 id="options">
Options
</h2>
<p>
The
<code>
HPEXPIREAT
</code>
command supports a set of options:
</p>
<ul>
<li>
<code>
NX
</code>
-- For each specified field, set expiration only when the field has no expiration.
</li>
<li>
<code>
XX
</code>
-- For each specified field, set expiration only when the field has an existing expiration.
</li>
<li>
<code>
GT
</code>
-- For each specified field, set expiration only when the new expiration is greater than current one.
</li>
<li>
<code>
LT
</code>
-- For each specified field, set expiration only when the new expiration is less than current one.
</li>
</ul>
<p>
A non-volatile key is treated as an infinite TTL for the purposes of
<code>
GT
</code>
and
<code>
LT
</code>
.
The
<code>
NX
</code>
,
<code>
XX
</code>
,
<code>
GT
</code>
, and
<code>
LT
</code>
options are mutually exclusive.
</p>
<h2 id="example">
Example
</h2>
<pre tabindex="0"><code>redis> HSET mykey field1 "hello" field2 "world"
(integer 2)
redis> HPEXPIREAT mykey 1715704971000 FIELDS 2 field1 field2
1) (integer) 1
2) (integer) 1
redis> HPTTL mykey FIELDS 2 field1 field2
1) (integer) 303340
2) (integer) 303340
</code></pre>
<h2 id="resp2resp3-reply">
RESP2/RESP3 Reply
</h2>
<p>
One of the following:
</p>
<ul>
<li>
<a href="../../develop/reference/protocol-spec#arrays">
Array reply
</a>
. For each field:
<ul>
<li>
<a href="../../develop/reference/protocol-spec#integers">
Integer reply
</a>
:
<code>
-2
</code>
if no such field exists in the provided hash key, or the provided key does not exist.
</li>
<li>
<a href="../../develop/reference/protocol-spec#integers">
Integer reply
</a>
:
<code>
0
</code>
if the specified NX, XX, GT, or LT condition has not been met.
</li>
<li>
<a href="../../develop/reference/protocol-spec#integers">
Integer reply
</a>
:
<code>
1
</code>
if the expiration time was set/updated.
</li>
<li>
<a href="../../develop/reference/protocol-spec#integers">
Integer reply
</a>
:
<code>
2
</code>
when
<code>
HEXPIRE
</code>
or
<code>
HPEXPIRE
</code>
is called with 0 seconds or milliseconds, or when
<code>
HEXPIREAT
</code>
or
<code>
HPEXPIREAT
</code>
is called with a past Unix time in seconds or milliseconds.
</li>
</ul>
</li>
<li>
<a href="../../develop/reference/protocol-spec#simple-errors">
Simple error reply
</a>
:
<ul>
<li>
if parsing failed, mandatory arguments are missing, unknown arguments are specified, or argument values are of the wrong type or out of range.
</li>
<li>
if the provided key exists but is not a hash.
</li>
</ul>
</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/hpexpireat/"/>
<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/role/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Role object
</h1>
<p class="text-lg -mt-5 mb-10">
An object that represents a role
</p>
<p>
An API object that represents a role.
</p>
<table>
<thead>
<tr>
<th>
Name
</th>
<th>
Type/Value
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
uid
</td>
<td>
integer
</td>
<td>
Role's unique ID
</td>
</tr>
<tr>
<td>
account_id
</td>
<td>
integer
</td>
<td>
SM account ID
</td>
</tr>
<tr>
<td>
action_uid
</td>
<td>
string
</td>
<td>
Action UID. If it exists, progress can be tracked by the GET /actions/{uid} API (read-only)
</td>
</tr>
<tr>
<td>
management
</td>
<td>
'admin'
<br/>
'db_member'
<br/>
'db_viewer'
<br/>
'cluster_member'
<br/>
'cluster_viewer'
<br/>
'user_manager'
<br/>
'none'
</td>
<td>
<a href="/docs/latest/operate/rs/references/rest-api/permissions/#roles">
Management role
</a>
</td>
</tr>
<tr>
<td>
name
</td>
<td>
string
</td>
<td>
Role's name
</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/role/"/>
<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/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Redis Enterprise Software
</h1>
<p class="text-lg -mt-5 mb-10">
The self-managed, enterprise-grade version of Redis.
</p>
<p>
<a href="https://redis.io/enterprise/">
Redis Enterprise
</a>
is a self-managed, enterprise-grade version of Redis.
</p>
<p>
With Redis Enterprise, you get many enterprise-grade capabilities, including:
</p>
<ul>
<li>
Linear scalability
</li>
<li>
High availability, backups, and recovery
</li>
<li>
Predictable performance
</li>
<li>
24/7 support
</li>
</ul>
<p>
You can run self-managed Redis Enterprise Software in an on-premises data center or on your preferred cloud platform.
</p>
<p>
If you prefer a fully managed Redis database-as-a-service, available on major public cloud services, consider setting up a
<a href="/docs/latest/operate/rc/">
Redis Cloud
</a>
subscription. You can
<a href="https://redis.io/try-free/">
try Redis Cloud
</a>
for free.
</p>
<h2 id="get-started">
Get started
</h2>
<p>
Build a small-scale cluster with the Redis Enterprise Software container image.
</p>
<ul>
<li>
<a href="/docs/latest/operate/rs/installing-upgrading/quickstarts/redis-enterprise-software-quickstart/">
Linux quickstart
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/installing-upgrading/quickstarts/docker-quickstart/">
Docker quickstart
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/databases/active-active/get-started/">
Get started with Active-Active
</a>
</li>
</ul>
<h2 id="install--setup">
Install & setup
</h2>
<p>
<a href="/docs/latest/operate/rs/installing-upgrading/">
Install & set up
</a>
a Redis Enterprise Software cluster.
</p>
<ul>
<li>
<a href="/docs/latest/operate/rs/networking/">
Networking
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/clusters/new-cluster-setup/">
Set up
</a>
&
<a href="/docs/latest/operate/rs/clusters/configure/">
configure
</a>
a
<a href="/docs/latest/operate/rs/clusters/">
cluster
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/release-notes/">
Release notes
</a>
</li>
</ul>
<h2 id="databases">
Databases
</h2>
<p>
Create and manage a
<a href="/docs/latest/operate/rs/databases/">
Redis database
</a>
on a cluster.
</p>
<ul>
<li>
<a href="/docs/latest/operate/rs/databases/create/">
Create a Redis Enterprise Software database
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/databases/configure/">
Configure database
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/databases/active-active/create/">
Create Active-Active database
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/databases/active-active/manage/">
Edit Active-Active database
</a>
</li>
</ul>
<h2 id="security">
Security
</h2>
<p>
<a href="/docs/latest/operate/rs/security/">
Manage secure connections
</a>
to the cluster and databases.
</p>
<ul>
<li>
<a href="/docs/latest/operate/rs/security/access-control/">
Access control
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/security/access-control/manage-users/">
Users
</a>
&
<a href="/docs/latest/operate/rs/security/access-control/">
roles
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/security/certificates/">
Certificates
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/security/encryption/tls/">
TLS
</a>
&
<a href="/docs/latest/operate/rs/security/encryption/">
Encryption
</a>
</li>
</ul>
<h2 id="reference">
Reference
</h2>
<p>
Use command-line utilities and the REST API to manage the cluster and databases.
</p>
<ul>
<li>
<a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/">
rladmin
</a>
,
<a href="/docs/latest/operate/rs/references/cli-utilities/crdb-cli/">
crdb-cli
</a>
, &
<a href="/docs/latest/operate/rs/references/cli-utilities/">
other utilities
</a>
</li>
<li>
<a href="/docs/latest/operate/rs/references/rest-api/">
REST API reference
</a>
&
<a href="/docs/latest/operate/rs/references/rest-api/quick-start/">
examples
</a>
</li>
<li>
<a href="/docs/latest/commands/">
Redis commands
</a>
</li>
</ul>
<h2 id="related-info">
Related info
</h2>
<ul>
<li>
<a href="/docs/latest/operate/rc/">
Redis Cloud
</a>
</li>
<li>
<a href="/docs/latest/operate/oss_and_stack/">
Redis Community Edition
</a>
</li>
<li>
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/">
Redis Stack
</a>
</li>
<li>
<a href="/docs/latest/glossary/">
Glossary
</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/"/>
<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.spellcheck.html | <section class="prose w-full py-12">
<h1 class="command-name">
FT.SPELLCHECK
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">FT.SPELLCHECK index query
[DISTANCE distance]
[TERMS INCLUDE | EXCLUDE dictionary [terms [terms ...]]]
[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.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>
Perform spelling correction on a query, returning suggestions for misspelled terms
</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 with the indexed terms.
</p>
</details>
<details open="">
<summary>
<code>
query
</code>
</summary>
<p>
is search query.
</p>
</details>
<p>
See
<a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/spellcheck/">
Spellchecking
</a>
for more details.
</p>
<h2 id="optional-arguments">
Optional arguments
</h2>
<details open="">
<summary>
<code>
TERMS
</code>
</summary>
<p>
specifies an inclusion (
<code>
INCLUDE
</code>
) or exclusion (
<code>
EXCLUDE
</code>
) of a custom dictionary. To learn more about managing custom dictionaries, see
<a href="/docs/latest/commands/ft.dictadd/">
<code>
FT.DICTADD
</code>
</a>
,
<a href="/docs/latest/commands/ft.dictdel/">
<code>
FT.DICTDEL
</code>
</a>
, and
<a href="/docs/latest/commands/ft.dictdump/">
<code>
FT.DICTDUMP
</code>
</a>
.
</p>
<p>
You can specify multiple inclusion and exclusion
<code>
TERMS
</code>
.
</p>
</details>
<details open="">
<summary>
<code>
DISTANCE
</code>
</summary>
<p>
is maximum Levenshtein distance for spelling suggestions (default: 1, max: 4).
</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.SPELLCHECK returns an array reply, in which each element represents a misspelled term from the query. The misspelled terms are ordered by their order of appearance in the query.
Each misspelled term, in turn, is a 3-element array consisting of the constant string
<code>
TERM
</code>
, the term itself and an array of suggestions for spelling corrections.
Each element in the spelling corrections array consists of the score of the suggestion and the suggestion itself. The suggestions array, per misspelled term, is ordered in descending order by score.
The score is calculated by dividing the number of documents in which the suggested term exists by the total number of documents in the index. Results can be normalized by dividing scores by the highest score.
</p>
<h2 id="examples">
Examples
</h2>
<details open="">
<summary>
<b>
Perform spelling correction on a query
</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> FT.SPELLCHECK idx held DISTANCE <span class="m">2</span>
</span></span><span class="line"><span class="cl">1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"TERM"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"held"</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> 1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"0.66666666666666663"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"hello"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"0.33333333333333331"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"help"</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.dictadd/">
<code>
FT.DICTADD
</code>
</a>
|
<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>
<ul>
<li>
<a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/spellcheck/">
Spellchecking
</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.spellcheck/"/>
<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/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/7.4/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/7.4/security/access-control/create-users/">
Cluster Manager UI
</a>
or a
<a href="/docs/latest/operate/rs/7.4/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="#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="#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="#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="#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>
</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
</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
</td>
</tr>
<tr>
<td>
<a name="create_new_user">
</a>
create_new_user
</td>
<td>
admin
</td>
</tr>
<tr>
<td>
<a name="create_redis_acl">
</a>
create_redis_acl
</td>
<td>
admin
</td>
</tr>
<tr>
<td>
<a name="create_role">
</a>
create_role
</td>
<td>
admin
</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
</td>
</tr>
<tr>
<td>
<a name="delete_redis_acl">
</a>
delete_redis_acl
</td>
<td>
admin
</td>
</tr>
<tr>
<td>
<a name="delete_role">
</a>
delete_role
</td>
<td>
admin
</td>
</tr>
<tr>
<td>
<a name="delete_user">
</a>
delete_user
</td>
<td>
admin
</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="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
</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
</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
</td>
</tr>
<tr>
<td>
<a name="update_redis_acl">
</a>
update_redis_acl
</td>
<td>
admin
</td>
</tr>
<tr>
<td>
<a name="update_role">
</a>
update_role
</td>
<td>
admin
</td>
</tr>
<tr>
<td>
<a name="update_user">
</a>
update_user
</td>
<td>
admin
</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
</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
</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
</td>
</tr>
<tr>
<td>
<a name="view_all_ldap_mappings_info">
</a>
view_all_ldap_mappings_info
</td>
<td>
admin
</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
</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
</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
</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
</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
</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
</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
</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
</td>
</tr>
<tr>
<td>
<a name="view_all_users_info">
</a>
view_all_users_info
</td>
<td>
admin
</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
</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
</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
</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
</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
</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
</td>
</tr>
<tr>
<td>
<a name="view_cluster_keys">
</a>
view_cluster_keys
</td>
<td>
admin
<br/>
cluster_member
</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
</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
</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
</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
</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
</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
</td>
</tr>
<tr>
<td>
<a name="view_debugging_info">
</a>
view_debugging_info
</td>
<td>
admin
<br/>
cluster_member
<br/>
db_member
<br/>
</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
</td>
</tr>
<tr>
<td>
<a name="view_ldap_config">
</a>
view_ldap_config
</td>
<td>
admin
</td>
</tr>
<tr>
<td>
<a name="view_ldap_mapping_info">
</a>
view_ldap_mapping_info
</td>
<td>
admin
</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
</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
</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
</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
</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
</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
</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
</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
</td>
</tr>
<tr>
<td>
<a name="view_redis_pass">
</a>
view_redis_pass
</td>
<td>
admin
<br/>
cluster_member
<br/>
db_member
</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
</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
</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
</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
</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
</td>
</tr>
<tr>
<td>
<a name="view_user_info">
</a>
view_user_info
</td>
<td>
admin
</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/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/operate/oss_and_stack/stack-with-enterprise/gears-v1/jvm/classes/gearsbuilder/flatmap/.html | <section class="prose w-full py-12 max-w-none">
<h1>
FlatMap
</h1>
<p class="text-lg -mt-5 mb-10">
Maps a single input record to one or more output records.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kd">public</span> <span class="o"><</span><span class="n">I</span> <span class="kd">extends</span> <span class="n">java</span><span class="o">.</span><span class="na">io</span><span class="o">.</span><span class="na">Serializable</span><span class="o">></span> <span class="n">GearsBuilder</span><span class="o"><</span><span class="n">I</span><span class="o">></span> <span class="n">flatMap</span><span class="err">β</span><span class="o">(</span>
</span></span><span class="line"><span class="cl"> <span class="n">gears</span><span class="o">.</span><span class="na">operations</span><span class="o">.</span><span class="na">FlatMapOperation</span><span class="o"><</span><span class="n">T</span><span class="o">,</span><span class="err">β</span><span class="n">I</span><span class="o">></span> <span class="n">flatmapper</span><span class="o">)</span>
</span></span></code></pre>
</div>
<p>
Maps a single input record to one or more output records.
</p>
<p>
The FlatMap operation must return an
<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html">
<code>
Iterable
</code>
</a>
. RedisGears
splits the elements from the
<code>
Iterable
</code>
object and processes them as individual records.
</p>
<h2 id="parameters">
Parameters
</h2>
<p>
Type parameters:
</p>
<table>
<thead>
<tr>
<th>
Name
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
I
</td>
<td>
The template type of the returned builder object
</td>
</tr>
</tbody>
</table>
<p>
Function parameters:
</p>
<table>
<thead>
<tr>
<th>
Name
</th>
<th>
Type
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
flatmapper
</td>
<td>
<nobr>
FlatMapOperation<T,βI>
</nobr>
</td>
<td>
For each input record, returns one or more output records
</td>
</tr>
</tbody>
</table>
<h2 id="returns">
Returns
</h2>
<p>
Returns a GearsBuilder object with a new template type.
</p>
<h2 id="example">
Example
</h2>
<div class="highlight">
<pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="n">GearsBuilder</span><span class="o">.</span><span class="na">CreateGearsBuilder</span><span class="o">(</span><span class="n">reader</span><span class="o">).</span><span class="na">flatMap</span><span class="o">(</span><span class="n">r</span><span class="o">->{</span>
</span></span><span class="line"><span class="cl"> <span class="k">return</span> <span class="n">r</span><span class="o">.</span><span class="na">getListVal</span><span class="o">();</span>
</span></span><span class="line"><span class="cl"><span class="o">});</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/oss_and_stack/stack-with-enterprise/gears-v1/jvm/classes/gearsbuilder/flatmap/"/>
<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/query/full-text/.html | <section class="prose w-full py-12">
<h1>
Full-text search
</h1>
<p class="text-lg -mt-5 mb-10">
Perform a full-text search
</p>
<p>
A full-text search finds words or phrases within larger texts. You can search within a specific text field or across all text fields.
</p>
<p>
This article provides a good overview of the most relevant full-text search capabilities. Please find further details about all the full-text search features in the
<a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/">
reference documentation
</a>
.
</p>
<p>
The examples in this article use a schema with the following fields:
</p>
<table>
<thead>
<tr>
<th>
Field name
</th>
<th>
Field type
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>
brand
</code>
</td>
<td>
<code>
TEXT
</code>
</td>
</tr>
<tr>
<td>
<code>
model
</code>
</td>
<td>
<code>
TEXT
</code>
</td>
</tr>
<tr>
<td>
<code>
description
</code>
</td>
<td>
<code>
TEXT
</code>
</td>
</tr>
</tbody>
</table>
<h2 id="single-word">
Single word
</h2>
<p>
To search for a word (or word stem) across all text fields, you can construct the following simple query:
</p>
<pre tabindex="0"><code>FT.SEARCH index "word"
</code></pre>
<p>
Instead of searching across all text fields, you might want to limit the search to a specific text field.
</p>
<pre tabindex="0"><code>FT.SEARCH index "@field: word"
</code></pre>
<p>
Words that occur very often in natural language, such as
<code>
the
</code>
or
<code>
a
</code>
for the English language, aren't indexed and will not return a search result. You can find further details in the
<a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/stopwords/">
stop words article
</a>
.
</p>
<p>
The following example searches for all bicycles that have the word 'kids' in the description:
</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="query_ft-stepft1">
<input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_query_ft-stepft1" name="query_ft-stepft1" 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_query_ft-stepft1" title="Open example">
>_ Redis CLI
</label>
<div aria-labelledby="tab-query_ft-stepft1" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_query_ft-stepft1" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">FT.SEARCH idx:bicycle "@description: kids"</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_query_ft-stepft1')" 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_query_ft-stepft1" name="query_ft-stepft1" 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_query_ft-stepft1" title="Open example">
Python
</label>
<div aria-labelledby="tab-query_ft-stepft1" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_query_ft-stepft1" 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="kn">import</span> <span class="nn">json</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">sys</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 class="kn">from</span> <span class="nn">redis.commands.json.path</span> <span class="kn">import</span> <span class="n">Path</span>
</span></span><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redis.commands.search.field</span> <span class="kn">import</span> <span class="n">TextField</span><span class="p">,</span> <span class="n">NumericField</span><span class="p">,</span> <span class="n">TagField</span>
</span></span><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redis.commands.search.indexDefinition</span> <span class="kn">import</span> <span class="n">IndexDefinition</span><span class="p">,</span> <span class="n">IndexType</span>
</span></span><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redis.commands.search.query</span> <span class="kn">import</span> <span class="n">NumericFilter</span><span class="p">,</span> <span class="n">Query</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 class="c1"># create index</span>
</span></span><span class="line"><span class="cl"><span class="n">schema</span> <span class="o">=</span> <span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="n">TextField</span><span class="p">(</span><span class="s2">"$.brand"</span><span class="p">,</span> <span class="n">as_name</span><span class="o">=</span><span class="s2">"brand"</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">TextField</span><span class="p">(</span><span class="s2">"$.model"</span><span class="p">,</span> <span class="n">as_name</span><span class="o">=</span><span class="s2">"model"</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">TextField</span><span class="p">(</span><span class="s2">"$.description"</span><span class="p">,</span> <span class="n">as_name</span><span class="o">=</span><span class="s2">"description"</span><span class="p">),</span>
</span></span><span class="line"><span 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">index</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ft</span><span class="p">(</span><span class="s2">"idx:bicycle"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">index</span><span class="o">.</span><span class="n">create_index</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="n">schema</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">definition</span><span class="o">=</span><span class="n">IndexDefinition</span><span class="p">(</span><span class="n">prefix</span><span class="o">=</span><span class="p">[</span><span class="s2">"bicycle:"</span><span class="p">],</span> <span class="n">index_type</span><span class="o">=</span><span class="n">IndexType</span><span class="o">.</span><span class="n">JSON</span><span class="p">),</span>
</span></span><span class="line"><span 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"># load data</span>
</span></span><span class="line"><span class="cl"><span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s2">"data/query_em.json"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
</span></span><span class="line"><span class="cl"> <span class="n">bicycles</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">pipeline</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">pipeline</span><span class="p">(</span><span class="n">transaction</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="k">for</span> <span class="n">bid</span><span class="p">,</span> <span class="n">bicycle</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">bicycles</span><span class="p">):</span>
</span></span><span class="line"><span class="cl"> <span class="n">pipeline</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="sa">f</span><span class="s1">'bicycle:</span><span class="si">{</span><span class="n">bid</span><span class="si">}</span><span class="s1">'</span><span class="p">,</span> <span class="n">Path</span><span class="o">.</span><span class="n">root_path</span><span class="p">(),</span> <span class="n">bicycle</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">pipeline</span><span class="o">.</span><span class="n">execute</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">Query</span><span class="p">(</span><span class="s2">"@description: kids"</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="o">.</span><span class="n">total</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="c1"># >>> 2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">Query</span><span class="p">(</span><span class="s2">"@model: ka*"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="o">.</span><span class="n">total</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> 1</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">Query</span><span class="p">(</span><span class="s2">"@brand: *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">res</span><span class="o">.</span><span class="n">total</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> 2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">Query</span><span class="p">(</span><span class="s2">"</span><span class="si">%o</span><span class="s2">ptamized%"</span><span class="p">))</span>
</span></span><span class="line"><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"><span class="cl"><span class="c1"># >>> Result{1 total, docs: [Document {'id': 'bicycle:3', 'payload': None, 'json': '{"pickup_zone":"POLYGON((-80.2433 25.8067, -80.1333 25.8067, -80.1333 25.6967, -80.2433 25.6967, -80.2433 25.8067))","store_location":"-80.1918,25.7617","brand":"Eva","model":"Eva 291","price":3400,"description":"The sister company to Nord, Eva launched in 2005 as the first and only women-dedicated bicycle brand. Designed by women for women, allEva bikes are optimized for the feminine physique using analytics from a body metrics database. If you like 29ers, try the Eva 291. Itβs a brand new bike for 2022.. This full-suspension, cross-country ride has been designed for velocity. The 291 has 100mm of front and rear travel, a superlight aluminum frame and fast-rolling 29-inch wheels. Yippee!","condition":"used"}'}]}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">Query</span><span class="p">(</span><span class="s2">"</span><span class="si">%%</span><span class="s2">optamised</span><span class="si">%%</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">res</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> Result{1 total, docs: [Document {'id': 'bicycle:3', 'payload': None, 'json': '{"pickup_zone":"POLYGON((-80.2433 25.8067, -80.1333 25.8067, -80.1333 25.6967, -80.2433 25.6967, -80.2433 25.8067))","store_location":"-80.1918,25.7617","brand":"Eva","model":"Eva 291","price":3400,"description":"The sister company to Nord, Eva launched in 2005 as the first and only women-dedicated bicycle brand. Designed by women for women, allEva bikes are optimized for the feminine physique using analytics from a body metrics database. If you like 29ers, try the Eva 291. Itβs a brand new bike for 2022.. This full-suspension, cross-country ride has been designed for velocity. The 291 has 100mm of front and rear travel, a superlight aluminum frame and fast-rolling 29-inch wheels. Yippee!","condition":"used"}'}]}</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_query_ft-stepft1')" 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_query_ft-stepft1" 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/query_ft.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_query_ft-stepft1" name="query_ft-stepft1" 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_query_ft-stepft1" title="Open example">
Node.js
</label>
<div aria-labelledby="tab-query_ft-stepft1" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_query_ft-stepft1" 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">'node:assert'</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">fs</span> <span class="nx">from</span> <span class="s1">'node:fs'</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">SchemaFieldTypes</span><span class="p">,</span> <span class="nx">AggregateGroupByReducers</span><span class="p">,</span> <span class="nx">AggregateSteps</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="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"><span class="cl"><span class="c1">// create index
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ft</span><span class="p">.</span><span class="nx">create</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="s1">'$.model'</span><span class="o">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">type</span><span class="o">:</span> <span class="nx">SchemaFieldTypes</span><span class="p">.</span><span class="nx">TEXT</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">AS</span><span class="o">:</span> <span class="s1">'model'</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="s1">'$.brand'</span><span class="o">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">type</span><span class="o">:</span> <span class="nx">SchemaFieldTypes</span><span class="p">.</span><span class="nx">TEXT</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">AS</span><span class="o">:</span> <span class="s1">'brand'</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="s1">'$.description'</span><span class="o">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">type</span><span class="o">:</span> <span class="nx">SchemaFieldTypes</span><span class="p">.</span><span class="nx">TEXT</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">AS</span><span class="o">:</span> <span class="s1">'description'</span>
</span></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="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ON</span><span class="o">:</span> <span class="s1">'JSON'</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">PREFIX</span><span class="o">:</span> <span class="s1">'bicycle:'</span>
</span></span><span class="line"><span 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">// load data
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">bicycles</span> <span class="o">=</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">fs</span><span class="p">.</span><span class="nx">readFileSync</span><span class="p">(</span><span class="s1">'data/query_em.json'</span><span class="p">,</span> <span class="s1">'utf8'</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="nb">Promise</span><span class="p">.</span><span class="nx">all</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="nx">bicycles</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">bicycle</span><span class="p">,</span> <span class="nx">bid</span><span class="p">)</span> <span class="p">=></span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">return</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="sb">`bicycle:</span><span class="si">${</span><span class="nx">bid</span><span class="si">}</span><span class="sb">`</span><span class="p">,</span> <span class="s1">'$'</span><span class="p">,</span> <span class="nx">bicycle</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="p">})</span>
</span></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="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">ft</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="s1">'@description: kids'</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="nx">total</span><span class="p">);</span> <span class="c1">// >>> 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">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ft</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="s1">'@model: ka*'</span><span class="p">);</span>
</span></span><span class="line"><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="nx">total</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">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ft</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="s1">'@brand: *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">res3</span><span class="p">.</span><span class="nx">total</span><span class="p">);</span> <span class="c1">// >>> 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">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ft</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="s1">'%optamized%'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> { total: 1, documents: [ { id: 'bicycle:3', value: [Object: null prototype] } ]}
</span></span></span><span class="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">ft</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="s1">'%%optamised%%'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> { total: 1, documents: [ { id: 'bicycle:3', value: [Object: null prototype] } ]}
</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_query_ft-stepft1')" 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_query_ft-stepft1" 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/query-ft.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_query_ft-stepft1" name="query_ft-stepft1" 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_query_ft-stepft1" title="Open example">
Java
</label>
<div aria-labelledby="tab-query_ft-stepft1" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_query_ft-stepft1" 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">java.util.List</span><span class="o">;</span>
</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 class="kn">import</span> <span class="nn">redis.clients.jedis.search.*</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.search.schemafields.*</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.exceptions.JedisDataException</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="kd">public</span> <span class="kd">class</span> <span class="nc">QueryFtExample</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">SchemaField</span><span class="o">[]</span> <span class="n">schema</span> <span class="o">=</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">TextField</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="s">"$.brand"</span><span class="o">).</span><span class="na">as</span><span class="o">(</span><span class="s">"brand"</span><span class="o">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">TextField</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="s">"$.model"</span><span class="o">).</span><span class="na">as</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">TextField</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="s">"$.description"</span><span class="o">).</span><span class="na">as</span><span class="o">(</span><span class="s">"description"</span><span class="o">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">NumericField</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="s">"$.price"</span><span class="o">).</span><span class="na">as</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">TagField</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="s">"$.condition"</span><span class="o">).</span><span class="na">as</span><span class="o">(</span><span class="s">"condition"</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></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">ftCreate</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">FTCreateParams</span><span class="o">.</span><span class="na">createParams</span><span class="o">()</span>
</span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">on</span><span class="o">(</span><span class="n">IndexDataType</span><span class="o">.</span><span class="na">JSON</span><span class="o">)</span>
</span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">addPrefix</span><span class="o">(</span><span class="s">"bicycle:"</span><span class="o">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">schema</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">String</span><span class="o">[]</span> <span class="n">bicycleJsons</span> <span class="o">=</span> <span class="k">new</span> <span class="n">String</span><span class="o">[]</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-74.0610 40.7578, -73.9510 40.7578, -73.9510 40.6678, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-74.0610 40.6678, -74.0610 40.7578))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-74.0060,40.7128\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Velorim\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Jigger\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 270,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"Small and powerful, the Jigger is the best ride for the smallest of tikes! "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"This is the tiniest kidsβ pedal bike on the market available without a coaster brake, the Jigger "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"is the vehicle of choice for the rare tenacious little rider raring to go.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"new\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-118.2887 34.0972, -118.1987 34.0972, -118.1987 33.9872, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-118.2887 33.9872, -118.2887 34.0972))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-118.2437,34.0522\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Bicyk\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Hillcraft\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1200,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"Kids want to ride with as little weight as possible. Especially "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"on an incline! They may be at the age when a 27.5'' wheel bike is just too clumsy coming "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"off a 24'' bike. The Hillcraft 26 is just the solution they need!\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"used\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-87.6848 41.9331, -87.5748 41.9331, -87.5748 41.8231, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-87.6848 41.8231, -87.6848 41.9331))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-87.6298,41.8781\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Nord\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Chook air 5\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 815,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"The Chook Air 5 gives kids aged six years and older a durable "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and uberlight mountain bike for their first experience on tracks and easy cruising through "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"forests and fields. The lower top tube makes it easy to mount and dismount in any "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"situation, giving your kids greater safety on the trails.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"used\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-80.2433 25.8067, -80.1333 25.8067, -80.1333 25.6967, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-80.2433 25.6967, -80.2433 25.8067))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-80.1918,25.7617\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Eva\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Eva 291\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3400,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"The sister company to Nord, Eva launched in 2005 as the first "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and only women-dedicated bicycle brand. Designed by women for women, allEva bikes "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"are optimized for the feminine physique using analytics from a body metrics database. "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"If you like 29ers, try the Eva 291. Itβs a brand new bike for 2022.. This "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"full-suspension, cross-country ride has been designed for velocity. The 291 has "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"100mm of front and rear travel, a superlight aluminum frame and fast-rolling "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"29-inch wheels. Yippee!\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"used\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-122.4644 37.8199, -122.3544 37.8199, -122.3544 37.7099, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-122.4644 37.7099, -122.4644 37.8199))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-122.4194,37.7749\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Noka Bikes\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Kahuna\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3200,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"Whether you want to try your hand at XC racing or are looking "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"for a lively trail bike that's just as inspiring on the climbs as it is over rougher "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"ground, the Wilder is one heck of a bike built specifically for short women. Both the "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"frames and components have been tweaked to include a womenβs saddle, different bars "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and unique colourway.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"used\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-0.1778 51.5524, 0.0822 51.5524, 0.0822 51.4024, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-0.1778 51.4024, -0.1778 51.5524))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-0.1278,51.5074\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Breakout\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"XBN 2.1 Alloy\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 810,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"The XBN 2.1 Alloy is our entry-level road bike β but thatβs "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"not to say that itβs a basic machine. With an internal weld aluminium frame, a full "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"carbon fork, and the slick-shifting Claris gears from Shimanoβs, this is a bike which "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"doesnβt break the bank and delivers craved performance.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"new\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((2.1767 48.9016, 2.5267 48.9016, 2.5267 48.5516, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"2.1767 48.5516, 2.1767 48.9016))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"2.3522,48.8566\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"ScramBikes\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"WattBike\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 2300,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"The WattBike is the best e-bike for people who still "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"feel young at heart. It has a Bafang 1000W mid-drive system and a 48V 17.5AH "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"Samsung Lithium-Ion battery, allowing you to ride for more than 60 miles on one "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"charge. Itβs great for tackling hilly terrain or if you just fancy a more "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"leisurely ride. With three working modes, you can choose between E-bike, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"assisted bicycle, and normal bike modes.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"new\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((13.3260 52.5700, 13.6550 52.5700, 13.6550 52.2700, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"13.3260 52.2700, 13.3260 52.5700))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"13.4050,52.5200\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Peaknetic\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Secto\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 430,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"If you struggle with stiff fingers or a kinked neck or "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"back after a few minutes on the road, this lightweight, aluminum bike alleviates "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"those issues and allows you to enjoy the ride. From the ergonomic grips to the "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"lumbar-supporting seat position, the Roll Low-Entry offers incredible comfort. "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"The rear-inclined seat tube facilitates stability by allowing you to put a foot "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"on the ground to balance at a stop, and the low step-over frame makes it "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"accessible for all ability and mobility levels. The saddle is very soft, with "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"a wide back to support your hip joints and a cutout in the center to redistribute "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"that pressure. Rim brakes deliver satisfactory braking control, and the wide tires "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"provide a smooth, stable ride on paved roads and gravel. Rack and fender mounts "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"facilitate setting up the Roll Low-Entry as your preferred commuter, and the "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"BMX-like handlebar offers space for mounting a flashlight, bell, or phone holder.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"new\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((1.9450 41.4301, 2.4018 41.4301, 2.4018 41.1987, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"1.9450 41.1987, 1.9450 41.4301))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"2.1734, 41.3851\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"nHill\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Summit\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1200,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This budget mountain bike from nHill performs well both "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"on bike paths and on the trail. The fork with 100mm of travel absorbs rough "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"terrain. Fat Kenda Booster tires give you grip in corners and on wet trails. "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"The Shimano Tourney drivetrain offered enough gears for finding a comfortable "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"pace to ride uphill, and the Tektro hydraulic disc brakes break smoothly. "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"Whether you want an affordable bike that you can take to work, but also take "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"trail in mountains on the weekends or youβre just after a stable, comfortable "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"ride for the bike path, the Summit gives a good value for money.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"new\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((12.4464 42.1028, 12.5464 42.1028, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"12.5464 41.7028, 12.4464 41.7028, 12.4464 42.1028))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"12.4964,41.9028\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"ThrillCycle\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"BikeShind\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 815,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"An artsy, retro-inspired bicycle thatβs as "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"functional as it is pretty: The ThrillCycle steel frame offers a smooth ride. "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"A 9-speed drivetrain has enough gears for coasting in the city, but we wouldnβt "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"suggest taking it to the mountains. Fenders protect you from mud, and a rear "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"basket lets you transport groceries, flowers and books. The ThrillCycle comes "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"with a limited lifetime warranty, so this little guy will last you long "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"past graduation.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"refurbished\""</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></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">bicycleJsons</span><span class="o">.</span><span class="na">length</span><span class="o">;</span> <span class="n">i</span><span class="o">++)</span> <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 class="s">"bicycle:"</span> <span class="o">+</span> <span class="n">i</span><span class="o">,</span> <span class="n">Path2</span><span class="o">.</span><span class="na">ROOT_PATH</span><span class="o">,</span> <span class="n">bicycleJsons</span><span class="o">[</span><span class="n">i</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></span><span class="line hl"><span class="cl"> <span class="n">SearchResult</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ftSearch</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span> <span class="s">"@description: kids"</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="na">getTotalResults</span><span class="o">());</span> <span class="c1">// >>> 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"><</span><span class="n">Document</span><span class="o">></span> <span class="n">docs1</span> <span class="o">=</span> <span class="n">res1</span><span class="o">.</span><span class="na">getDocuments</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">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">docs1</span><span class="o">.</span><span class="na">size</span><span class="o">();</span> <span class="n">i</span><span class="o">++)</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">docs1</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">getId</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="c1">// >>> bicycle:2
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="c1">// >>> bicycle:1
</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 'ft1' 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">SearchResult</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ftSearch</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span> <span class="s">"@model: ka*"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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="na">getTotalResults</span><span class="o">());</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="n">List</span><span class="o"><</span><span class="n">Document</span><span class="o">></span> <span class="n">docs2</span> <span class="o">=</span> <span class="n">res2</span><span class="o">.</span><span class="na">getDocuments</span><span class="o">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">docs2</span><span class="o">.</span><span class="na">size</span><span class="o">();</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">docs2</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">getId</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="c1">// >>> bicycle:4
</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 'ft2' 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">SearchResult</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ftSearch</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span> <span class="s">"@brand: *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">res3</span><span class="o">.</span><span class="na">getTotalResults</span><span class="o">());</span> <span class="c1">// >>> 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"><</span><span class="n">Document</span><span class="o">></span> <span class="n">docs3</span> <span class="o">=</span> <span class="n">res3</span><span class="o">.</span><span class="na">getDocuments</span><span class="o">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">docs3</span><span class="o">.</span><span class="na">size</span><span class="o">();</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">docs3</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">getId</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="c1">// >>> bicycle:6
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// >>> bicycle:4
</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 'ft3' 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">SearchResult</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ftSearch</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span> <span class="s">"%optamized%"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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="na">getTotalResults</span><span class="o">());</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="n">List</span><span class="o"><</span><span class="n">Document</span><span class="o">></span> <span class="n">docs4</span> <span class="o">=</span> <span class="n">res4</span><span class="o">.</span><span class="na">getDocuments</span><span class="o">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">docs4</span><span class="o">.</span><span class="na">size</span><span class="o">();</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">docs4</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">getId</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="c1">// >>> bicycle:3
</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 'ft4' 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">SearchResult</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ftSearch</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span> <span class="s">"%%optamised%%"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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="na">getTotalResults</span><span class="o">());</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="n">List</span><span class="o"><</span><span class="n">Document</span><span class="o">></span> <span class="n">docs5</span> <span class="o">=</span> <span class="n">res5</span><span class="o">.</span><span class="na">getDocuments</span><span class="o">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">docs5</span><span class="o">.</span><span class="na">size</span><span class="o">();</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">docs5</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">getId</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="c1">// >>> bicycle:3
</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 'ft5' 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_query_ft-stepft1')" 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_query_ft-stepft1" 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/QueryFtExample.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="dotnet" id="Csharp_query_ft-stepft1" name="query_ft-stepft1" 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_query_ft-stepft1" title="Open example">
C#
</label>
<div aria-labelledby="tab-query_ft-stepft1" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_query_ft-stepft1" 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.Search</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Search.Literals.Enums</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">QueryFtExample</span>
</span></span><span class="line"><span 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 class="n">Schema</span> <span class="n">bikeSchema</span> <span class="p">=</span> <span class="k">new</span> <span class="n">Schema</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddTextField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.brand"</span><span class="p">,</span> <span class="s">"brand"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddTextField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.model"</span><span class="p">,</span> <span class="s">"model"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddTextField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.description"</span><span class="p">,</span> <span class="s">"description"</span><span class="p">));</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">FTCreateParams</span> <span class="n">bikeParams</span> <span class="p">=</span> <span class="k">new</span> <span class="n">FTCreateParams</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddPrefix</span><span class="p">(</span><span class="s">"bicycle:"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">On</span><span class="p">(</span><span class="n">IndexDataType</span><span class="p">.</span><span class="n">JSON</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Create</span><span class="p">(</span><span class="s">"idx:bicycle"</span><span class="p">,</span> <span class="n">bikeParams</span><span class="p">,</span> <span class="n">bikeSchema</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">bicycles</span> <span class="p">=</span> <span class="k">new</span> <span class="kt">object</span><span class="p">[]</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Velorim"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Jigger"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">270</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"Small and powerful, the Jigger is the best ride "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"for the smallest of tikes! This is the tiniest "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"kidsβ pedal bike on the market available without"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" a coaster brake, the Jigger is the vehicle of "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"choice for the rare tenacious little rider "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"raring to go."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"used"</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Bicyk"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Hillcraft"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">1200</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"Kids want to ride with as little weight as possible."</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" Especially on an incline! They may be at the age "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"when a 27.5 inch wheel bike is just too clumsy coming "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"off a 24 inch bike. The Hillcraft 26 is just the solution"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" they need!"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"used"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Nord"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Chook air 5"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">815</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"The Chook Air 5 gives kids aged six years and older "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"a durable and uberlight mountain bike for their first"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" experience on tracks and easy cruising through forests"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" and fields. The lower top tube makes it easy to mount"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" and dismount in any situation, giving your kids greater"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" safety on the trails."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"used"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Eva"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Eva 291"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">3400</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"The sister company to Nord, Eva launched in 2005 as the"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" first and only women-dedicated bicycle brand. Designed"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" by women for women, allEva bikes are optimized for the"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" feminine physique using analytics from a body metrics"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" database. If you like 29ers, try the Eva 291. Itβs a "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"brand new bike for 2022.. This full-suspension, "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"cross-country ride has been designed for velocity. The"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" 291 has 100mm of front and rear travel, a superlight "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"aluminum frame and fast-rolling 29-inch wheels. Yippee!"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"used"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Noka Bikes"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Kahuna"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">3200</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"Whether you want to try your hand at XC racing or are "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"looking for a lively trail bike that's just as inspiring"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" on the climbs as it is over rougher ground, the Wilder"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" is one heck of a bike built specifically for short women."</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" Both the frames and components have been tweaked to "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"include a womenβs saddle, different bars and unique "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"colourway."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"used"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Breakout"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"XBN 2.1 Alloy"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">810</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"The XBN 2.1 Alloy is our entry-level road bike β but thatβs"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" not to say that itβs a basic machine. With an internal "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"weld aluminium frame, a full carbon fork, and the slick-shifting"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" Claris gears from Shimanoβs, this is a bike which doesnβt"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" break the bank and delivers craved performance."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"new"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"ScramBikes"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"WattBike"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">2300</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"The WattBike is the best e-bike for people who still feel young"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" at heart. It has a Bafang 1000W mid-drive system and a 48V"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" 17.5AH Samsung Lithium-Ion battery, allowing you to ride for"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" more than 60 miles on one charge. Itβs great for tackling hilly"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" terrain or if you just fancy a more leisurely ride. With three"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" working modes, you can choose between E-bike, assisted bicycle,"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" and normal bike modes."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"new"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Peaknetic"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Secto"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">430</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"If you struggle with stiff fingers or a kinked neck or back after"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" a few minutes on the road, this lightweight, aluminum bike"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" alleviates those issues and allows you to enjoy the ride. From"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" the ergonomic grips to the lumbar-supporting seat position, the"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" Roll Low-Entry offers incredible comfort. The rear-inclined seat"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" tube facilitates stability by allowing you to put a foot on the"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" ground to balance at a stop, and the low step-over frame makes it"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" accessible for all ability and mobility levels. The saddle is"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" very soft, with a wide back to support your hip joints and a"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" cutout in the center to redistribute that pressure. Rim brakes"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" deliver satisfactory braking control, and the wide tires provide"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" a smooth, stable ride on paved roads and gravel. Rack and fender"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" mounts facilitate setting up the Roll Low-Entry as your preferred"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" commuter, and the BMX-like handlebar offers space for mounting a"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" flashlight, bell, or phone holder."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"new"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"nHill"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Summit"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">1200</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"This budget mountain bike from nHill performs well both on bike"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" paths and on the trail. The fork with 100mm of travel absorbs"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" rough terrain. Fat Kenda Booster tires give you grip in corners"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" and on wet trails. The Shimano Tourney drivetrain offered enough"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" gears for finding a comfortable pace to ride uphill, and the"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" Tektro hydraulic disc brakes break smoothly. Whether you want an"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" affordable bike that you can take to work, but also take trail in"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" mountains on the weekends or youβre just after a stable,"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" comfortable ride for the bike path, the Summit gives a good value"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" for money."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"new"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"ThrillCycle"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"BikeShind"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">815</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"An artsy, retro-inspired bicycle thatβs as functional as it is"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" pretty: The ThrillCycle steel frame offers a smooth ride. A"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" 9-speed drivetrain has enough gears for coasting in the city, but"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" we wouldnβt suggest taking it to the mountains. Fenders protect"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" you from mud, and a rear basket lets you transport groceries,"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" flowers and books. The ThrillCycle comes with a limited lifetime"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" warranty, so this little guy will last you long past graduation."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"refurbished"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span 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">for</span> <span class="p">(</span><span class="kt">var</span> <span class="n">i</span> <span class="p">=</span> <span class="m">0</span><span class="p">;</span> <span class="n">i</span> <span class="p"><</span> <span class="n">bicycles</span><span class="p">.</span><span class="n">Length</span><span class="p">;</span> <span class="n">i</span><span class="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">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">$"bicycle:{i}"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">bicycles</span><span class="p">[</span><span class="n">i</span><span class="p">]);</span>
</span></span><span class="line"><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 hl"><span class="cl"> <span class="n">SearchResult</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"idx:bicycle"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"@description: kids"</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="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">// >>> 2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'ft1' 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">SearchResult</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:bicycle"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"@model: ka*"</span><span class="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">res2</span><span class="p">.</span><span class="n">TotalResults</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="c1">// Tests for 'ft2' 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">SearchResult</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:bicycle"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"@brand: *bikes"</span><span class="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">res3</span><span class="p">.</span><span class="n">TotalResults</span><span class="p">);</span> <span class="c1">// >>> 2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'ft3' 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">SearchResult</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:bicycle"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"%optamized%"</span><span class="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">res4</span><span class="p">.</span><span class="n">TotalResults</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="c1">// Tests for 'ft4' 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">SearchResult</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:bicycle"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"%%optamised%%"</span><span class="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">res5</span><span class="p">.</span><span class="n">TotalResults</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="c1">// Tests for 'ft5' 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_query_ft-stepft1')" 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_query_ft-stepft1" 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/QueryFtExample.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="phrase">
Phrase
</h2>
<p>
A phrase is a sentence, sentence fragment, or small group of words. You can find further details about how to find exact phrases in the
<a href="/docs/latest/develop/interact/search-and-query/query/exact-match/">
exact match article
</a>
.
</p>
<h2 id="word-prefix">
Word prefix
</h2>
<p>
You can also search for words that match a given prefix.
</p>
<pre tabindex="0"><code>FT.SEARCH index "prefix*"
</code></pre>
<pre tabindex="0"><code>FT.SEARCH index "@field: prefix*"
</code></pre>
<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">
Important:
</div>
The prefix needs to be at least two characters long.
</div>
</div>
<p>
Here is an example that shows you how to search for bicycles with a brand that starts with 'ka':
</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="query_ft-stepft2">
<input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_query_ft-stepft2" name="query_ft-stepft2" 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_query_ft-stepft2" title="Open example">
>_ Redis CLI
</label>
<div aria-labelledby="tab-query_ft-stepft2" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_query_ft-stepft2" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">FT.SEARCH idx:bicycle "@model: ka*"</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_query_ft-stepft2')" 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_query_ft-stepft2" name="query_ft-stepft2" 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_query_ft-stepft2" title="Open example">
Python
</label>
<div aria-labelledby="tab-query_ft-stepft2" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_query_ft-stepft2" 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="kn">import</span> <span class="nn">json</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">sys</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 class="kn">from</span> <span class="nn">redis.commands.json.path</span> <span class="kn">import</span> <span class="n">Path</span>
</span></span><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redis.commands.search.field</span> <span class="kn">import</span> <span class="n">TextField</span><span class="p">,</span> <span class="n">NumericField</span><span class="p">,</span> <span class="n">TagField</span>
</span></span><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redis.commands.search.indexDefinition</span> <span class="kn">import</span> <span class="n">IndexDefinition</span><span class="p">,</span> <span class="n">IndexType</span>
</span></span><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redis.commands.search.query</span> <span class="kn">import</span> <span class="n">NumericFilter</span><span class="p">,</span> <span class="n">Query</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 class="c1"># create index</span>
</span></span><span class="line"><span class="cl"><span class="n">schema</span> <span class="o">=</span> <span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="n">TextField</span><span class="p">(</span><span class="s2">"$.brand"</span><span class="p">,</span> <span class="n">as_name</span><span class="o">=</span><span class="s2">"brand"</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">TextField</span><span class="p">(</span><span class="s2">"$.model"</span><span class="p">,</span> <span class="n">as_name</span><span class="o">=</span><span class="s2">"model"</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">TextField</span><span class="p">(</span><span class="s2">"$.description"</span><span class="p">,</span> <span class="n">as_name</span><span class="o">=</span><span class="s2">"description"</span><span class="p">),</span>
</span></span><span class="line"><span 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">index</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ft</span><span class="p">(</span><span class="s2">"idx:bicycle"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">index</span><span class="o">.</span><span class="n">create_index</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="n">schema</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">definition</span><span class="o">=</span><span class="n">IndexDefinition</span><span class="p">(</span><span class="n">prefix</span><span class="o">=</span><span class="p">[</span><span class="s2">"bicycle:"</span><span class="p">],</span> <span class="n">index_type</span><span class="o">=</span><span class="n">IndexType</span><span class="o">.</span><span class="n">JSON</span><span class="p">),</span>
</span></span><span class="line"><span 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"># load data</span>
</span></span><span class="line"><span class="cl"><span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s2">"data/query_em.json"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
</span></span><span class="line"><span class="cl"> <span class="n">bicycles</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">pipeline</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">pipeline</span><span class="p">(</span><span class="n">transaction</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="k">for</span> <span class="n">bid</span><span class="p">,</span> <span class="n">bicycle</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">bicycles</span><span class="p">):</span>
</span></span><span class="line"><span class="cl"> <span class="n">pipeline</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="sa">f</span><span class="s1">'bicycle:</span><span class="si">{</span><span class="n">bid</span><span class="si">}</span><span class="s1">'</span><span class="p">,</span> <span class="n">Path</span><span class="o">.</span><span class="n">root_path</span><span class="p">(),</span> <span class="n">bicycle</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">pipeline</span><span class="o">.</span><span class="n">execute</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">Query</span><span class="p">(</span><span class="s2">"@description: kids"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="o">.</span><span class="n">total</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> 2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">Query</span><span class="p">(</span><span class="s2">"@model: ka*"</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="o">.</span><span class="n">total</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="c1"># >>> 1</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">Query</span><span class="p">(</span><span class="s2">"@brand: *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">res</span><span class="o">.</span><span class="n">total</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> 2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">Query</span><span class="p">(</span><span class="s2">"</span><span class="si">%o</span><span class="s2">ptamized%"</span><span class="p">))</span>
</span></span><span class="line"><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"><span class="cl"><span class="c1"># >>> Result{1 total, docs: [Document {'id': 'bicycle:3', 'payload': None, 'json': '{"pickup_zone":"POLYGON((-80.2433 25.8067, -80.1333 25.8067, -80.1333 25.6967, -80.2433 25.6967, -80.2433 25.8067))","store_location":"-80.1918,25.7617","brand":"Eva","model":"Eva 291","price":3400,"description":"The sister company to Nord, Eva launched in 2005 as the first and only women-dedicated bicycle brand. Designed by women for women, allEva bikes are optimized for the feminine physique using analytics from a body metrics database. If you like 29ers, try the Eva 291. Itβs a brand new bike for 2022.. This full-suspension, cross-country ride has been designed for velocity. The 291 has 100mm of front and rear travel, a superlight aluminum frame and fast-rolling 29-inch wheels. Yippee!","condition":"used"}'}]}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">Query</span><span class="p">(</span><span class="s2">"</span><span class="si">%%</span><span class="s2">optamised</span><span class="si">%%</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">res</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> Result{1 total, docs: [Document {'id': 'bicycle:3', 'payload': None, 'json': '{"pickup_zone":"POLYGON((-80.2433 25.8067, -80.1333 25.8067, -80.1333 25.6967, -80.2433 25.6967, -80.2433 25.8067))","store_location":"-80.1918,25.7617","brand":"Eva","model":"Eva 291","price":3400,"description":"The sister company to Nord, Eva launched in 2005 as the first and only women-dedicated bicycle brand. Designed by women for women, allEva bikes are optimized for the feminine physique using analytics from a body metrics database. If you like 29ers, try the Eva 291. Itβs a brand new bike for 2022.. This full-suspension, cross-country ride has been designed for velocity. The 291 has 100mm of front and rear travel, a superlight aluminum frame and fast-rolling 29-inch wheels. Yippee!","condition":"used"}'}]}</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_query_ft-stepft2')" 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_query_ft-stepft2" 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/query_ft.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_query_ft-stepft2" name="query_ft-stepft2" 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_query_ft-stepft2" title="Open example">
Node.js
</label>
<div aria-labelledby="tab-query_ft-stepft2" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_query_ft-stepft2" 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">'node:assert'</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">fs</span> <span class="nx">from</span> <span class="s1">'node:fs'</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">SchemaFieldTypes</span><span class="p">,</span> <span class="nx">AggregateGroupByReducers</span><span class="p">,</span> <span class="nx">AggregateSteps</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="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"><span class="cl"><span class="c1">// create index
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ft</span><span class="p">.</span><span class="nx">create</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="s1">'$.model'</span><span class="o">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">type</span><span class="o">:</span> <span class="nx">SchemaFieldTypes</span><span class="p">.</span><span class="nx">TEXT</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">AS</span><span class="o">:</span> <span class="s1">'model'</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="s1">'$.brand'</span><span class="o">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">type</span><span class="o">:</span> <span class="nx">SchemaFieldTypes</span><span class="p">.</span><span class="nx">TEXT</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">AS</span><span class="o">:</span> <span class="s1">'brand'</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="s1">'$.description'</span><span class="o">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">type</span><span class="o">:</span> <span class="nx">SchemaFieldTypes</span><span class="p">.</span><span class="nx">TEXT</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">AS</span><span class="o">:</span> <span class="s1">'description'</span>
</span></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="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ON</span><span class="o">:</span> <span class="s1">'JSON'</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">PREFIX</span><span class="o">:</span> <span class="s1">'bicycle:'</span>
</span></span><span class="line"><span 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">// load data
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">bicycles</span> <span class="o">=</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">fs</span><span class="p">.</span><span class="nx">readFileSync</span><span class="p">(</span><span class="s1">'data/query_em.json'</span><span class="p">,</span> <span class="s1">'utf8'</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="nb">Promise</span><span class="p">.</span><span class="nx">all</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="nx">bicycles</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">bicycle</span><span class="p">,</span> <span class="nx">bid</span><span class="p">)</span> <span class="p">=></span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">return</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="sb">`bicycle:</span><span class="si">${</span><span class="nx">bid</span><span class="si">}</span><span class="sb">`</span><span class="p">,</span> <span class="s1">'$'</span><span class="p">,</span> <span class="nx">bicycle</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="p">})</span>
</span></span><span class="line"><span 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">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ft</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="s1">'@description: kids'</span><span class="p">);</span>
</span></span><span class="line"><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="nx">total</span><span class="p">);</span> <span class="c1">// >>> 2
</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">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ft</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="s1">'@model: ka*'</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="nx">total</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">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ft</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="s1">'@brand: *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">res3</span><span class="p">.</span><span class="nx">total</span><span class="p">);</span> <span class="c1">// >>> 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">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ft</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="s1">'%optamized%'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> { total: 1, documents: [ { id: 'bicycle:3', value: [Object: null prototype] } ]}
</span></span></span><span class="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">ft</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="s1">'%%optamised%%'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> { total: 1, documents: [ { id: 'bicycle:3', value: [Object: null prototype] } ]}
</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_query_ft-stepft2')" 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_query_ft-stepft2" 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/query-ft.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_query_ft-stepft2" name="query_ft-stepft2" 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_query_ft-stepft2" title="Open example">
Java
</label>
<div aria-labelledby="tab-query_ft-stepft2" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_query_ft-stepft2" 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">java.util.List</span><span class="o">;</span>
</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 class="kn">import</span> <span class="nn">redis.clients.jedis.search.*</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.search.schemafields.*</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.exceptions.JedisDataException</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="kd">public</span> <span class="kd">class</span> <span class="nc">QueryFtExample</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">SchemaField</span><span class="o">[]</span> <span class="n">schema</span> <span class="o">=</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">TextField</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="s">"$.brand"</span><span class="o">).</span><span class="na">as</span><span class="o">(</span><span class="s">"brand"</span><span class="o">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">TextField</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="s">"$.model"</span><span class="o">).</span><span class="na">as</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">TextField</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="s">"$.description"</span><span class="o">).</span><span class="na">as</span><span class="o">(</span><span class="s">"description"</span><span class="o">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">NumericField</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="s">"$.price"</span><span class="o">).</span><span class="na">as</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">TagField</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="s">"$.condition"</span><span class="o">).</span><span class="na">as</span><span class="o">(</span><span class="s">"condition"</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></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">ftCreate</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">FTCreateParams</span><span class="o">.</span><span class="na">createParams</span><span class="o">()</span>
</span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">on</span><span class="o">(</span><span class="n">IndexDataType</span><span class="o">.</span><span class="na">JSON</span><span class="o">)</span>
</span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">addPrefix</span><span class="o">(</span><span class="s">"bicycle:"</span><span class="o">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">schema</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">String</span><span class="o">[]</span> <span class="n">bicycleJsons</span> <span class="o">=</span> <span class="k">new</span> <span class="n">String</span><span class="o">[]</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-74.0610 40.7578, -73.9510 40.7578, -73.9510 40.6678, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-74.0610 40.6678, -74.0610 40.7578))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-74.0060,40.7128\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Velorim\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Jigger\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 270,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"Small and powerful, the Jigger is the best ride for the smallest of tikes! "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"This is the tiniest kidsβ pedal bike on the market available without a coaster brake, the Jigger "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"is the vehicle of choice for the rare tenacious little rider raring to go.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"new\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-118.2887 34.0972, -118.1987 34.0972, -118.1987 33.9872, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-118.2887 33.9872, -118.2887 34.0972))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-118.2437,34.0522\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Bicyk\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Hillcraft\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1200,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"Kids want to ride with as little weight as possible. Especially "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"on an incline! They may be at the age when a 27.5'' wheel bike is just too clumsy coming "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"off a 24'' bike. The Hillcraft 26 is just the solution they need!\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"used\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-87.6848 41.9331, -87.5748 41.9331, -87.5748 41.8231, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-87.6848 41.8231, -87.6848 41.9331))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-87.6298,41.8781\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Nord\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Chook air 5\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 815,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"The Chook Air 5 gives kids aged six years and older a durable "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and uberlight mountain bike for their first experience on tracks and easy cruising through "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"forests and fields. The lower top tube makes it easy to mount and dismount in any "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"situation, giving your kids greater safety on the trails.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"used\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-80.2433 25.8067, -80.1333 25.8067, -80.1333 25.6967, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-80.2433 25.6967, -80.2433 25.8067))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-80.1918,25.7617\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Eva\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Eva 291\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3400,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"The sister company to Nord, Eva launched in 2005 as the first "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and only women-dedicated bicycle brand. Designed by women for women, allEva bikes "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"are optimized for the feminine physique using analytics from a body metrics database. "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"If you like 29ers, try the Eva 291. Itβs a brand new bike for 2022.. This "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"full-suspension, cross-country ride has been designed for velocity. The 291 has "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"100mm of front and rear travel, a superlight aluminum frame and fast-rolling "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"29-inch wheels. Yippee!\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"used\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-122.4644 37.8199, -122.3544 37.8199, -122.3544 37.7099, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-122.4644 37.7099, -122.4644 37.8199))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-122.4194,37.7749\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Noka Bikes\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Kahuna\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3200,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"Whether you want to try your hand at XC racing or are looking "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"for a lively trail bike that's just as inspiring on the climbs as it is over rougher "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"ground, the Wilder is one heck of a bike built specifically for short women. Both the "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"frames and components have been tweaked to include a womenβs saddle, different bars "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and unique colourway.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"used\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-0.1778 51.5524, 0.0822 51.5524, 0.0822 51.4024, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-0.1778 51.4024, -0.1778 51.5524))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-0.1278,51.5074\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Breakout\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"XBN 2.1 Alloy\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 810,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"The XBN 2.1 Alloy is our entry-level road bike β but thatβs "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"not to say that itβs a basic machine. With an internal weld aluminium frame, a full "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"carbon fork, and the slick-shifting Claris gears from Shimanoβs, this is a bike which "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"doesnβt break the bank and delivers craved performance.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"new\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((2.1767 48.9016, 2.5267 48.9016, 2.5267 48.5516, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"2.1767 48.5516, 2.1767 48.9016))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"2.3522,48.8566\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"ScramBikes\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"WattBike\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 2300,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"The WattBike is the best e-bike for people who still "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"feel young at heart. It has a Bafang 1000W mid-drive system and a 48V 17.5AH "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"Samsung Lithium-Ion battery, allowing you to ride for more than 60 miles on one "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"charge. Itβs great for tackling hilly terrain or if you just fancy a more "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"leisurely ride. With three working modes, you can choose between E-bike, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"assisted bicycle, and normal bike modes.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"new\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((13.3260 52.5700, 13.6550 52.5700, 13.6550 52.2700, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"13.3260 52.2700, 13.3260 52.5700))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"13.4050,52.5200\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Peaknetic\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Secto\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 430,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"If you struggle with stiff fingers or a kinked neck or "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"back after a few minutes on the road, this lightweight, aluminum bike alleviates "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"those issues and allows you to enjoy the ride. From the ergonomic grips to the "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"lumbar-supporting seat position, the Roll Low-Entry offers incredible comfort. "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"The rear-inclined seat tube facilitates stability by allowing you to put a foot "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"on the ground to balance at a stop, and the low step-over frame makes it "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"accessible for all ability and mobility levels. The saddle is very soft, with "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"a wide back to support your hip joints and a cutout in the center to redistribute "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"that pressure. Rim brakes deliver satisfactory braking control, and the wide tires "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"provide a smooth, stable ride on paved roads and gravel. Rack and fender mounts "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"facilitate setting up the Roll Low-Entry as your preferred commuter, and the "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"BMX-like handlebar offers space for mounting a flashlight, bell, or phone holder.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"new\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((1.9450 41.4301, 2.4018 41.4301, 2.4018 41.1987, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"1.9450 41.1987, 1.9450 41.4301))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"2.1734, 41.3851\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"nHill\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Summit\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1200,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This budget mountain bike from nHill performs well both "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"on bike paths and on the trail. The fork with 100mm of travel absorbs rough "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"terrain. Fat Kenda Booster tires give you grip in corners and on wet trails. "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"The Shimano Tourney drivetrain offered enough gears for finding a comfortable "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"pace to ride uphill, and the Tektro hydraulic disc brakes break smoothly. "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"Whether you want an affordable bike that you can take to work, but also take "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"trail in mountains on the weekends or youβre just after a stable, comfortable "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"ride for the bike path, the Summit gives a good value for money.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"new\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((12.4464 42.1028, 12.5464 42.1028, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"12.5464 41.7028, 12.4464 41.7028, 12.4464 42.1028))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"12.4964,41.9028\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"ThrillCycle\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"BikeShind\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 815,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"An artsy, retro-inspired bicycle thatβs as "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"functional as it is pretty: The ThrillCycle steel frame offers a smooth ride. "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"A 9-speed drivetrain has enough gears for coasting in the city, but we wouldnβt "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"suggest taking it to the mountains. Fenders protect you from mud, and a rear "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"basket lets you transport groceries, flowers and books. The ThrillCycle comes "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"with a limited lifetime warranty, so this little guy will last you long "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"past graduation.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"refurbished\""</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></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">bicycleJsons</span><span class="o">.</span><span class="na">length</span><span class="o">;</span> <span class="n">i</span><span class="o">++)</span> <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 class="s">"bicycle:"</span> <span class="o">+</span> <span class="n">i</span><span class="o">,</span> <span class="n">Path2</span><span class="o">.</span><span class="na">ROOT_PATH</span><span class="o">,</span> <span class="n">bicycleJsons</span><span class="o">[</span><span class="n">i</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></span><span class="line"><span class="cl"> <span class="n">SearchResult</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ftSearch</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span> <span class="s">"@description: kids"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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="na">getTotalResults</span><span class="o">());</span> <span class="c1">// >>> 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"><</span><span class="n">Document</span><span class="o">></span> <span class="n">docs1</span> <span class="o">=</span> <span class="n">res1</span><span class="o">.</span><span class="na">getDocuments</span><span class="o">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">docs1</span><span class="o">.</span><span class="na">size</span><span class="o">();</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">docs1</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">getId</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="c1">// >>> bicycle:2
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// >>> bicycle:1
</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 'ft1' 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">SearchResult</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ftSearch</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span> <span class="s">"@model: ka*"</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="na">getTotalResults</span><span class="o">());</span> <span class="c1">// >>> 1
</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"><</span><span class="n">Document</span><span class="o">></span> <span class="n">docs2</span> <span class="o">=</span> <span class="n">res2</span><span class="o">.</span><span class="na">getDocuments</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">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">docs2</span><span class="o">.</span><span class="na">size</span><span class="o">();</span> <span class="n">i</span><span class="o">++)</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">docs2</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">getId</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="c1">// >>> bicycle:4
</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 'ft2' 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">SearchResult</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ftSearch</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span> <span class="s">"@brand: *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">res3</span><span class="o">.</span><span class="na">getTotalResults</span><span class="o">());</span> <span class="c1">// >>> 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"><</span><span class="n">Document</span><span class="o">></span> <span class="n">docs3</span> <span class="o">=</span> <span class="n">res3</span><span class="o">.</span><span class="na">getDocuments</span><span class="o">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">docs3</span><span class="o">.</span><span class="na">size</span><span class="o">();</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">docs3</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">getId</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="c1">// >>> bicycle:6
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// >>> bicycle:4
</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 'ft3' 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">SearchResult</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ftSearch</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span> <span class="s">"%optamized%"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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="na">getTotalResults</span><span class="o">());</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="n">List</span><span class="o"><</span><span class="n">Document</span><span class="o">></span> <span class="n">docs4</span> <span class="o">=</span> <span class="n">res4</span><span class="o">.</span><span class="na">getDocuments</span><span class="o">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">docs4</span><span class="o">.</span><span class="na">size</span><span class="o">();</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">docs4</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">getId</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="c1">// >>> bicycle:3
</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 'ft4' 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">SearchResult</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ftSearch</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span> <span class="s">"%%optamised%%"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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="na">getTotalResults</span><span class="o">());</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="n">List</span><span class="o"><</span><span class="n">Document</span><span class="o">></span> <span class="n">docs5</span> <span class="o">=</span> <span class="n">res5</span><span class="o">.</span><span class="na">getDocuments</span><span class="o">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">docs5</span><span class="o">.</span><span class="na">size</span><span class="o">();</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">docs5</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">getId</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="c1">// >>> bicycle:3
</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 'ft5' 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_query_ft-stepft2')" 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_query_ft-stepft2" 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/QueryFtExample.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="dotnet" id="Csharp_query_ft-stepft2" name="query_ft-stepft2" 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_query_ft-stepft2" title="Open example">
C#
</label>
<div aria-labelledby="tab-query_ft-stepft2" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_query_ft-stepft2" 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.Search</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Search.Literals.Enums</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">QueryFtExample</span>
</span></span><span class="line"><span 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 class="n">Schema</span> <span class="n">bikeSchema</span> <span class="p">=</span> <span class="k">new</span> <span class="n">Schema</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddTextField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.brand"</span><span class="p">,</span> <span class="s">"brand"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddTextField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.model"</span><span class="p">,</span> <span class="s">"model"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddTextField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.description"</span><span class="p">,</span> <span class="s">"description"</span><span class="p">));</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">FTCreateParams</span> <span class="n">bikeParams</span> <span class="p">=</span> <span class="k">new</span> <span class="n">FTCreateParams</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddPrefix</span><span class="p">(</span><span class="s">"bicycle:"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">On</span><span class="p">(</span><span class="n">IndexDataType</span><span class="p">.</span><span class="n">JSON</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Create</span><span class="p">(</span><span class="s">"idx:bicycle"</span><span class="p">,</span> <span class="n">bikeParams</span><span class="p">,</span> <span class="n">bikeSchema</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">bicycles</span> <span class="p">=</span> <span class="k">new</span> <span class="kt">object</span><span class="p">[]</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Velorim"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Jigger"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">270</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"Small and powerful, the Jigger is the best ride "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"for the smallest of tikes! This is the tiniest "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"kidsβ pedal bike on the market available without"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" a coaster brake, the Jigger is the vehicle of "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"choice for the rare tenacious little rider "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"raring to go."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"used"</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Bicyk"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Hillcraft"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">1200</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"Kids want to ride with as little weight as possible."</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" Especially on an incline! They may be at the age "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"when a 27.5 inch wheel bike is just too clumsy coming "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"off a 24 inch bike. The Hillcraft 26 is just the solution"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" they need!"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"used"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Nord"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Chook air 5"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">815</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"The Chook Air 5 gives kids aged six years and older "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"a durable and uberlight mountain bike for their first"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" experience on tracks and easy cruising through forests"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" and fields. The lower top tube makes it easy to mount"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" and dismount in any situation, giving your kids greater"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" safety on the trails."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"used"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Eva"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Eva 291"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">3400</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"The sister company to Nord, Eva launched in 2005 as the"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" first and only women-dedicated bicycle brand. Designed"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" by women for women, allEva bikes are optimized for the"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" feminine physique using analytics from a body metrics"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" database. If you like 29ers, try the Eva 291. Itβs a "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"brand new bike for 2022.. This full-suspension, "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"cross-country ride has been designed for velocity. The"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" 291 has 100mm of front and rear travel, a superlight "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"aluminum frame and fast-rolling 29-inch wheels. Yippee!"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"used"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Noka Bikes"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Kahuna"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">3200</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"Whether you want to try your hand at XC racing or are "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"looking for a lively trail bike that's just as inspiring"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" on the climbs as it is over rougher ground, the Wilder"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" is one heck of a bike built specifically for short women."</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" Both the frames and components have been tweaked to "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"include a womenβs saddle, different bars and unique "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"colourway."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"used"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Breakout"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"XBN 2.1 Alloy"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">810</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"The XBN 2.1 Alloy is our entry-level road bike β but thatβs"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" not to say that itβs a basic machine. With an internal "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"weld aluminium frame, a full carbon fork, and the slick-shifting"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" Claris gears from Shimanoβs, this is a bike which doesnβt"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" break the bank and delivers craved performance."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"new"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"ScramBikes"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"WattBike"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">2300</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"The WattBike is the best e-bike for people who still feel young"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" at heart. It has a Bafang 1000W mid-drive system and a 48V"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" 17.5AH Samsung Lithium-Ion battery, allowing you to ride for"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" more than 60 miles on one charge. Itβs great for tackling hilly"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" terrain or if you just fancy a more leisurely ride. With three"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" working modes, you can choose between E-bike, assisted bicycle,"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" and normal bike modes."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"new"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Peaknetic"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Secto"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">430</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"If you struggle with stiff fingers or a kinked neck or back after"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" a few minutes on the road, this lightweight, aluminum bike"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" alleviates those issues and allows you to enjoy the ride. From"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" the ergonomic grips to the lumbar-supporting seat position, the"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" Roll Low-Entry offers incredible comfort. The rear-inclined seat"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" tube facilitates stability by allowing you to put a foot on the"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" ground to balance at a stop, and the low step-over frame makes it"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" accessible for all ability and mobility levels. The saddle is"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" very soft, with a wide back to support your hip joints and a"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" cutout in the center to redistribute that pressure. Rim brakes"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" deliver satisfactory braking control, and the wide tires provide"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" a smooth, stable ride on paved roads and gravel. Rack and fender"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" mounts facilitate setting up the Roll Low-Entry as your preferred"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" commuter, and the BMX-like handlebar offers space for mounting a"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" flashlight, bell, or phone holder."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"new"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"nHill"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Summit"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">1200</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"This budget mountain bike from nHill performs well both on bike"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" paths and on the trail. The fork with 100mm of travel absorbs"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" rough terrain. Fat Kenda Booster tires give you grip in corners"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" and on wet trails. The Shimano Tourney drivetrain offered enough"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" gears for finding a comfortable pace to ride uphill, and the"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" Tektro hydraulic disc brakes break smoothly. Whether you want an"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" affordable bike that you can take to work, but also take trail in"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" mountains on the weekends or youβre just after a stable,"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" comfortable ride for the bike path, the Summit gives a good value"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" for money."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"new"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"ThrillCycle"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"BikeShind"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">815</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"An artsy, retro-inspired bicycle thatβs as functional as it is"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" pretty: The ThrillCycle steel frame offers a smooth ride. A"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" 9-speed drivetrain has enough gears for coasting in the city, but"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" we wouldnβt suggest taking it to the mountains. Fenders protect"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" you from mud, and a rear basket lets you transport groceries,"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" flowers and books. The ThrillCycle comes with a limited lifetime"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" warranty, so this little guy will last you long past graduation."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"refurbished"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span 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">for</span> <span class="p">(</span><span class="kt">var</span> <span class="n">i</span> <span class="p">=</span> <span class="m">0</span><span class="p">;</span> <span class="n">i</span> <span class="p"><</span> <span class="n">bicycles</span><span class="p">.</span><span class="n">Length</span><span class="p">;</span> <span class="n">i</span><span class="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">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">$"bicycle:{i}"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">bicycles</span><span class="p">[</span><span class="n">i</span><span class="p">]);</span>
</span></span><span class="line"><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="n">SearchResult</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:bicycle"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"@description: kids"</span><span class="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">res1</span><span class="p">);</span> <span class="c1">// >>> 2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'ft1' 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">SearchResult</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"idx:bicycle"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"@model: ka*"</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="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="n">TotalResults</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="c1">// Tests for 'ft2' 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">SearchResult</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:bicycle"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"@brand: *bikes"</span><span class="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">res3</span><span class="p">.</span><span class="n">TotalResults</span><span class="p">);</span> <span class="c1">// >>> 2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'ft3' 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">SearchResult</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:bicycle"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"%optamized%"</span><span class="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">res4</span><span class="p">.</span><span class="n">TotalResults</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="c1">// Tests for 'ft4' 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">SearchResult</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:bicycle"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"%%optamised%%"</span><span class="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">res5</span><span class="p">.</span><span class="n">TotalResults</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="c1">// Tests for 'ft5' 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_query_ft-stepft2')" 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_query_ft-stepft2" 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/QueryFtExample.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="word-suffix">
Word suffix
</h2>
<p>
Similar to the prefix, it is also possible to search for words that share the same suffix.
</p>
<pre tabindex="0"><code>FT.SEARCH index "*suffix"
</code></pre>
<p>
You can also combine prefix- and suffix-based searches within a query expression.
</p>
<pre tabindex="0"><code>FT.SEARCH index "*infix*"
</code></pre>
<p>
Here is an example that finds all brands that end with '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="query_ft-stepft3">
<input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_query_ft-stepft3" name="query_ft-stepft3" 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_query_ft-stepft3" title="Open example">
>_ Redis CLI
</label>
<div aria-labelledby="tab-query_ft-stepft3" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_query_ft-stepft3" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">FT.SEARCH idx:bicycle "@brand:*bikes"</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_query_ft-stepft3')" 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_query_ft-stepft3" name="query_ft-stepft3" 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_query_ft-stepft3" title="Open example">
Python
</label>
<div aria-labelledby="tab-query_ft-stepft3" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_query_ft-stepft3" 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="kn">import</span> <span class="nn">json</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">sys</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 class="kn">from</span> <span class="nn">redis.commands.json.path</span> <span class="kn">import</span> <span class="n">Path</span>
</span></span><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redis.commands.search.field</span> <span class="kn">import</span> <span class="n">TextField</span><span class="p">,</span> <span class="n">NumericField</span><span class="p">,</span> <span class="n">TagField</span>
</span></span><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redis.commands.search.indexDefinition</span> <span class="kn">import</span> <span class="n">IndexDefinition</span><span class="p">,</span> <span class="n">IndexType</span>
</span></span><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redis.commands.search.query</span> <span class="kn">import</span> <span class="n">NumericFilter</span><span class="p">,</span> <span class="n">Query</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 class="c1"># create index</span>
</span></span><span class="line"><span class="cl"><span class="n">schema</span> <span class="o">=</span> <span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="n">TextField</span><span class="p">(</span><span class="s2">"$.brand"</span><span class="p">,</span> <span class="n">as_name</span><span class="o">=</span><span class="s2">"brand"</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">TextField</span><span class="p">(</span><span class="s2">"$.model"</span><span class="p">,</span> <span class="n">as_name</span><span class="o">=</span><span class="s2">"model"</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">TextField</span><span class="p">(</span><span class="s2">"$.description"</span><span class="p">,</span> <span class="n">as_name</span><span class="o">=</span><span class="s2">"description"</span><span class="p">),</span>
</span></span><span class="line"><span 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">index</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ft</span><span class="p">(</span><span class="s2">"idx:bicycle"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">index</span><span class="o">.</span><span class="n">create_index</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="n">schema</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">definition</span><span class="o">=</span><span class="n">IndexDefinition</span><span class="p">(</span><span class="n">prefix</span><span class="o">=</span><span class="p">[</span><span class="s2">"bicycle:"</span><span class="p">],</span> <span class="n">index_type</span><span class="o">=</span><span class="n">IndexType</span><span class="o">.</span><span class="n">JSON</span><span class="p">),</span>
</span></span><span class="line"><span 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"># load data</span>
</span></span><span class="line"><span class="cl"><span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s2">"data/query_em.json"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
</span></span><span class="line"><span class="cl"> <span class="n">bicycles</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">pipeline</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">pipeline</span><span class="p">(</span><span class="n">transaction</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="k">for</span> <span class="n">bid</span><span class="p">,</span> <span class="n">bicycle</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">bicycles</span><span class="p">):</span>
</span></span><span class="line"><span class="cl"> <span class="n">pipeline</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="sa">f</span><span class="s1">'bicycle:</span><span class="si">{</span><span class="n">bid</span><span class="si">}</span><span class="s1">'</span><span class="p">,</span> <span class="n">Path</span><span class="o">.</span><span class="n">root_path</span><span class="p">(),</span> <span class="n">bicycle</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">pipeline</span><span class="o">.</span><span class="n">execute</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">Query</span><span class="p">(</span><span class="s2">"@description: kids"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="o">.</span><span class="n">total</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> 2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">Query</span><span class="p">(</span><span class="s2">"@model: ka*"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="o">.</span><span class="n">total</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> 1</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">Query</span><span class="p">(</span><span class="s2">"@brand: *bikes"</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="o">.</span><span class="n">total</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="c1"># >>> 2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">Query</span><span class="p">(</span><span class="s2">"</span><span class="si">%o</span><span class="s2">ptamized%"</span><span class="p">))</span>
</span></span><span class="line"><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"><span class="cl"><span class="c1"># >>> Result{1 total, docs: [Document {'id': 'bicycle:3', 'payload': None, 'json': '{"pickup_zone":"POLYGON((-80.2433 25.8067, -80.1333 25.8067, -80.1333 25.6967, -80.2433 25.6967, -80.2433 25.8067))","store_location":"-80.1918,25.7617","brand":"Eva","model":"Eva 291","price":3400,"description":"The sister company to Nord, Eva launched in 2005 as the first and only women-dedicated bicycle brand. Designed by women for women, allEva bikes are optimized for the feminine physique using analytics from a body metrics database. If you like 29ers, try the Eva 291. Itβs a brand new bike for 2022.. This full-suspension, cross-country ride has been designed for velocity. The 291 has 100mm of front and rear travel, a superlight aluminum frame and fast-rolling 29-inch wheels. Yippee!","condition":"used"}'}]}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">Query</span><span class="p">(</span><span class="s2">"</span><span class="si">%%</span><span class="s2">optamised</span><span class="si">%%</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">res</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> Result{1 total, docs: [Document {'id': 'bicycle:3', 'payload': None, 'json': '{"pickup_zone":"POLYGON((-80.2433 25.8067, -80.1333 25.8067, -80.1333 25.6967, -80.2433 25.6967, -80.2433 25.8067))","store_location":"-80.1918,25.7617","brand":"Eva","model":"Eva 291","price":3400,"description":"The sister company to Nord, Eva launched in 2005 as the first and only women-dedicated bicycle brand. Designed by women for women, allEva bikes are optimized for the feminine physique using analytics from a body metrics database. If you like 29ers, try the Eva 291. Itβs a brand new bike for 2022.. This full-suspension, cross-country ride has been designed for velocity. The 291 has 100mm of front and rear travel, a superlight aluminum frame and fast-rolling 29-inch wheels. Yippee!","condition":"used"}'}]}</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_query_ft-stepft3')" 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_query_ft-stepft3" 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/query_ft.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_query_ft-stepft3" name="query_ft-stepft3" 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_query_ft-stepft3" title="Open example">
Node.js
</label>
<div aria-labelledby="tab-query_ft-stepft3" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_query_ft-stepft3" 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">'node:assert'</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">fs</span> <span class="nx">from</span> <span class="s1">'node:fs'</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">SchemaFieldTypes</span><span class="p">,</span> <span class="nx">AggregateGroupByReducers</span><span class="p">,</span> <span class="nx">AggregateSteps</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="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"><span class="cl"><span class="c1">// create index
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ft</span><span class="p">.</span><span class="nx">create</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="s1">'$.model'</span><span class="o">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">type</span><span class="o">:</span> <span class="nx">SchemaFieldTypes</span><span class="p">.</span><span class="nx">TEXT</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">AS</span><span class="o">:</span> <span class="s1">'model'</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="s1">'$.brand'</span><span class="o">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">type</span><span class="o">:</span> <span class="nx">SchemaFieldTypes</span><span class="p">.</span><span class="nx">TEXT</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">AS</span><span class="o">:</span> <span class="s1">'brand'</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="s1">'$.description'</span><span class="o">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">type</span><span class="o">:</span> <span class="nx">SchemaFieldTypes</span><span class="p">.</span><span class="nx">TEXT</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">AS</span><span class="o">:</span> <span class="s1">'description'</span>
</span></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="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ON</span><span class="o">:</span> <span class="s1">'JSON'</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">PREFIX</span><span class="o">:</span> <span class="s1">'bicycle:'</span>
</span></span><span class="line"><span 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">// load data
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">bicycles</span> <span class="o">=</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">fs</span><span class="p">.</span><span class="nx">readFileSync</span><span class="p">(</span><span class="s1">'data/query_em.json'</span><span class="p">,</span> <span class="s1">'utf8'</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="nb">Promise</span><span class="p">.</span><span class="nx">all</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="nx">bicycles</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">bicycle</span><span class="p">,</span> <span class="nx">bid</span><span class="p">)</span> <span class="p">=></span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">return</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="sb">`bicycle:</span><span class="si">${</span><span class="nx">bid</span><span class="si">}</span><span class="sb">`</span><span class="p">,</span> <span class="s1">'$'</span><span class="p">,</span> <span class="nx">bicycle</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="p">})</span>
</span></span><span class="line"><span 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">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ft</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="s1">'@description: kids'</span><span class="p">);</span>
</span></span><span class="line"><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="nx">total</span><span class="p">);</span> <span class="c1">// >>> 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">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ft</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="s1">'@model: ka*'</span><span class="p">);</span>
</span></span><span class="line"><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="nx">total</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 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">ft</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="s1">'@brand: *bikes'</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="nx">total</span><span class="p">);</span> <span class="c1">// >>> 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">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ft</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="s1">'%optamized%'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> { total: 1, documents: [ { id: 'bicycle:3', value: [Object: null prototype] } ]}
</span></span></span><span class="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">ft</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="s1">'%%optamised%%'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> { total: 1, documents: [ { id: 'bicycle:3', value: [Object: null prototype] } ]}
</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_query_ft-stepft3')" 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_query_ft-stepft3" 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/query-ft.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_query_ft-stepft3" name="query_ft-stepft3" 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_query_ft-stepft3" title="Open example">
Java
</label>
<div aria-labelledby="tab-query_ft-stepft3" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_query_ft-stepft3" 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">java.util.List</span><span class="o">;</span>
</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 class="kn">import</span> <span class="nn">redis.clients.jedis.search.*</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.search.schemafields.*</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.exceptions.JedisDataException</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="kd">public</span> <span class="kd">class</span> <span class="nc">QueryFtExample</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">SchemaField</span><span class="o">[]</span> <span class="n">schema</span> <span class="o">=</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">TextField</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="s">"$.brand"</span><span class="o">).</span><span class="na">as</span><span class="o">(</span><span class="s">"brand"</span><span class="o">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">TextField</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="s">"$.model"</span><span class="o">).</span><span class="na">as</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">TextField</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="s">"$.description"</span><span class="o">).</span><span class="na">as</span><span class="o">(</span><span class="s">"description"</span><span class="o">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">NumericField</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="s">"$.price"</span><span class="o">).</span><span class="na">as</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">TagField</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="s">"$.condition"</span><span class="o">).</span><span class="na">as</span><span class="o">(</span><span class="s">"condition"</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></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">ftCreate</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">FTCreateParams</span><span class="o">.</span><span class="na">createParams</span><span class="o">()</span>
</span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">on</span><span class="o">(</span><span class="n">IndexDataType</span><span class="o">.</span><span class="na">JSON</span><span class="o">)</span>
</span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">addPrefix</span><span class="o">(</span><span class="s">"bicycle:"</span><span class="o">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">schema</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">String</span><span class="o">[]</span> <span class="n">bicycleJsons</span> <span class="o">=</span> <span class="k">new</span> <span class="n">String</span><span class="o">[]</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-74.0610 40.7578, -73.9510 40.7578, -73.9510 40.6678, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-74.0610 40.6678, -74.0610 40.7578))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-74.0060,40.7128\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Velorim\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Jigger\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 270,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"Small and powerful, the Jigger is the best ride for the smallest of tikes! "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"This is the tiniest kidsβ pedal bike on the market available without a coaster brake, the Jigger "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"is the vehicle of choice for the rare tenacious little rider raring to go.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"new\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-118.2887 34.0972, -118.1987 34.0972, -118.1987 33.9872, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-118.2887 33.9872, -118.2887 34.0972))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-118.2437,34.0522\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Bicyk\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Hillcraft\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1200,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"Kids want to ride with as little weight as possible. Especially "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"on an incline! They may be at the age when a 27.5'' wheel bike is just too clumsy coming "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"off a 24'' bike. The Hillcraft 26 is just the solution they need!\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"used\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-87.6848 41.9331, -87.5748 41.9331, -87.5748 41.8231, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-87.6848 41.8231, -87.6848 41.9331))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-87.6298,41.8781\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Nord\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Chook air 5\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 815,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"The Chook Air 5 gives kids aged six years and older a durable "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and uberlight mountain bike for their first experience on tracks and easy cruising through "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"forests and fields. The lower top tube makes it easy to mount and dismount in any "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"situation, giving your kids greater safety on the trails.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"used\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-80.2433 25.8067, -80.1333 25.8067, -80.1333 25.6967, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-80.2433 25.6967, -80.2433 25.8067))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-80.1918,25.7617\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Eva\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Eva 291\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3400,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"The sister company to Nord, Eva launched in 2005 as the first "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and only women-dedicated bicycle brand. Designed by women for women, allEva bikes "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"are optimized for the feminine physique using analytics from a body metrics database. "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"If you like 29ers, try the Eva 291. Itβs a brand new bike for 2022.. This "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"full-suspension, cross-country ride has been designed for velocity. The 291 has "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"100mm of front and rear travel, a superlight aluminum frame and fast-rolling "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"29-inch wheels. Yippee!\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"used\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-122.4644 37.8199, -122.3544 37.8199, -122.3544 37.7099, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-122.4644 37.7099, -122.4644 37.8199))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-122.4194,37.7749\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Noka Bikes\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Kahuna\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3200,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"Whether you want to try your hand at XC racing or are looking "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"for a lively trail bike that's just as inspiring on the climbs as it is over rougher "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"ground, the Wilder is one heck of a bike built specifically for short women. Both the "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"frames and components have been tweaked to include a womenβs saddle, different bars "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and unique colourway.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"used\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-0.1778 51.5524, 0.0822 51.5524, 0.0822 51.4024, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-0.1778 51.4024, -0.1778 51.5524))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-0.1278,51.5074\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Breakout\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"XBN 2.1 Alloy\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 810,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"The XBN 2.1 Alloy is our entry-level road bike β but thatβs "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"not to say that itβs a basic machine. With an internal weld aluminium frame, a full "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"carbon fork, and the slick-shifting Claris gears from Shimanoβs, this is a bike which "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"doesnβt break the bank and delivers craved performance.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"new\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((2.1767 48.9016, 2.5267 48.9016, 2.5267 48.5516, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"2.1767 48.5516, 2.1767 48.9016))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"2.3522,48.8566\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"ScramBikes\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"WattBike\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 2300,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"The WattBike is the best e-bike for people who still "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"feel young at heart. It has a Bafang 1000W mid-drive system and a 48V 17.5AH "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"Samsung Lithium-Ion battery, allowing you to ride for more than 60 miles on one "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"charge. Itβs great for tackling hilly terrain or if you just fancy a more "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"leisurely ride. With three working modes, you can choose between E-bike, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"assisted bicycle, and normal bike modes.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"new\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((13.3260 52.5700, 13.6550 52.5700, 13.6550 52.2700, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"13.3260 52.2700, 13.3260 52.5700))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"13.4050,52.5200\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Peaknetic\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Secto\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 430,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"If you struggle with stiff fingers or a kinked neck or "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"back after a few minutes on the road, this lightweight, aluminum bike alleviates "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"those issues and allows you to enjoy the ride. From the ergonomic grips to the "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"lumbar-supporting seat position, the Roll Low-Entry offers incredible comfort. "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"The rear-inclined seat tube facilitates stability by allowing you to put a foot "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"on the ground to balance at a stop, and the low step-over frame makes it "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"accessible for all ability and mobility levels. The saddle is very soft, with "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"a wide back to support your hip joints and a cutout in the center to redistribute "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"that pressure. Rim brakes deliver satisfactory braking control, and the wide tires "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"provide a smooth, stable ride on paved roads and gravel. Rack and fender mounts "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"facilitate setting up the Roll Low-Entry as your preferred commuter, and the "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"BMX-like handlebar offers space for mounting a flashlight, bell, or phone holder.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"new\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((1.9450 41.4301, 2.4018 41.4301, 2.4018 41.1987, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"1.9450 41.1987, 1.9450 41.4301))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"2.1734, 41.3851\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"nHill\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Summit\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1200,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This budget mountain bike from nHill performs well both "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"on bike paths and on the trail. The fork with 100mm of travel absorbs rough "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"terrain. Fat Kenda Booster tires give you grip in corners and on wet trails. "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"The Shimano Tourney drivetrain offered enough gears for finding a comfortable "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"pace to ride uphill, and the Tektro hydraulic disc brakes break smoothly. "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"Whether you want an affordable bike that you can take to work, but also take "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"trail in mountains on the weekends or youβre just after a stable, comfortable "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"ride for the bike path, the Summit gives a good value for money.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"new\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((12.4464 42.1028, 12.5464 42.1028, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"12.5464 41.7028, 12.4464 41.7028, 12.4464 42.1028))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"12.4964,41.9028\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"ThrillCycle\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"BikeShind\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 815,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"An artsy, retro-inspired bicycle thatβs as "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"functional as it is pretty: The ThrillCycle steel frame offers a smooth ride. "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"A 9-speed drivetrain has enough gears for coasting in the city, but we wouldnβt "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"suggest taking it to the mountains. Fenders protect you from mud, and a rear "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"basket lets you transport groceries, flowers and books. The ThrillCycle comes "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"with a limited lifetime warranty, so this little guy will last you long "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"past graduation.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"refurbished\""</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></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">bicycleJsons</span><span class="o">.</span><span class="na">length</span><span class="o">;</span> <span class="n">i</span><span class="o">++)</span> <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 class="s">"bicycle:"</span> <span class="o">+</span> <span class="n">i</span><span class="o">,</span> <span class="n">Path2</span><span class="o">.</span><span class="na">ROOT_PATH</span><span class="o">,</span> <span class="n">bicycleJsons</span><span class="o">[</span><span class="n">i</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></span><span class="line"><span class="cl"> <span class="n">SearchResult</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ftSearch</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span> <span class="s">"@description: kids"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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="na">getTotalResults</span><span class="o">());</span> <span class="c1">// >>> 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"><</span><span class="n">Document</span><span class="o">></span> <span class="n">docs1</span> <span class="o">=</span> <span class="n">res1</span><span class="o">.</span><span class="na">getDocuments</span><span class="o">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">docs1</span><span class="o">.</span><span class="na">size</span><span class="o">();</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">docs1</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">getId</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="c1">// >>> bicycle:2
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// >>> bicycle:1
</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 'ft1' 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">SearchResult</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ftSearch</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span> <span class="s">"@model: ka*"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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="na">getTotalResults</span><span class="o">());</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="n">List</span><span class="o"><</span><span class="n">Document</span><span class="o">></span> <span class="n">docs2</span> <span class="o">=</span> <span class="n">res2</span><span class="o">.</span><span class="na">getDocuments</span><span class="o">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">docs2</span><span class="o">.</span><span class="na">size</span><span class="o">();</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">docs2</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">getId</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="c1">// >>> bicycle:4
</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 'ft2' 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">SearchResult</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ftSearch</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span> <span class="s">"@brand: *bikes"</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="na">getTotalResults</span><span class="o">());</span> <span class="c1">// >>> 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"><</span><span class="n">Document</span><span class="o">></span> <span class="n">docs3</span> <span class="o">=</span> <span class="n">res3</span><span class="o">.</span><span class="na">getDocuments</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">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">docs3</span><span class="o">.</span><span class="na">size</span><span class="o">();</span> <span class="n">i</span><span class="o">++)</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">docs3</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">getId</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="c1">// >>> bicycle:6
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="c1">// >>> bicycle:4
</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 'ft3' 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">SearchResult</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ftSearch</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span> <span class="s">"%optamized%"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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="na">getTotalResults</span><span class="o">());</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="n">List</span><span class="o"><</span><span class="n">Document</span><span class="o">></span> <span class="n">docs4</span> <span class="o">=</span> <span class="n">res4</span><span class="o">.</span><span class="na">getDocuments</span><span class="o">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">docs4</span><span class="o">.</span><span class="na">size</span><span class="o">();</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">docs4</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">getId</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="c1">// >>> bicycle:3
</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 'ft4' 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">SearchResult</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ftSearch</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span> <span class="s">"%%optamised%%"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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="na">getTotalResults</span><span class="o">());</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="n">List</span><span class="o"><</span><span class="n">Document</span><span class="o">></span> <span class="n">docs5</span> <span class="o">=</span> <span class="n">res5</span><span class="o">.</span><span class="na">getDocuments</span><span class="o">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">docs5</span><span class="o">.</span><span class="na">size</span><span class="o">();</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">docs5</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">getId</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="c1">// >>> bicycle:3
</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 'ft5' 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_query_ft-stepft3')" 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_query_ft-stepft3" 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/QueryFtExample.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="dotnet" id="Csharp_query_ft-stepft3" name="query_ft-stepft3" 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_query_ft-stepft3" title="Open example">
C#
</label>
<div aria-labelledby="tab-query_ft-stepft3" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_query_ft-stepft3" 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.Search</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Search.Literals.Enums</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">QueryFtExample</span>
</span></span><span class="line"><span 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 class="n">Schema</span> <span class="n">bikeSchema</span> <span class="p">=</span> <span class="k">new</span> <span class="n">Schema</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddTextField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.brand"</span><span class="p">,</span> <span class="s">"brand"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddTextField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.model"</span><span class="p">,</span> <span class="s">"model"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddTextField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.description"</span><span class="p">,</span> <span class="s">"description"</span><span class="p">));</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">FTCreateParams</span> <span class="n">bikeParams</span> <span class="p">=</span> <span class="k">new</span> <span class="n">FTCreateParams</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddPrefix</span><span class="p">(</span><span class="s">"bicycle:"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">On</span><span class="p">(</span><span class="n">IndexDataType</span><span class="p">.</span><span class="n">JSON</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Create</span><span class="p">(</span><span class="s">"idx:bicycle"</span><span class="p">,</span> <span class="n">bikeParams</span><span class="p">,</span> <span class="n">bikeSchema</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">bicycles</span> <span class="p">=</span> <span class="k">new</span> <span class="kt">object</span><span class="p">[]</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Velorim"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Jigger"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">270</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"Small and powerful, the Jigger is the best ride "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"for the smallest of tikes! This is the tiniest "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"kidsβ pedal bike on the market available without"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" a coaster brake, the Jigger is the vehicle of "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"choice for the rare tenacious little rider "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"raring to go."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"used"</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Bicyk"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Hillcraft"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">1200</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"Kids want to ride with as little weight as possible."</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" Especially on an incline! They may be at the age "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"when a 27.5 inch wheel bike is just too clumsy coming "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"off a 24 inch bike. The Hillcraft 26 is just the solution"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" they need!"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"used"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Nord"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Chook air 5"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">815</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"The Chook Air 5 gives kids aged six years and older "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"a durable and uberlight mountain bike for their first"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" experience on tracks and easy cruising through forests"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" and fields. The lower top tube makes it easy to mount"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" and dismount in any situation, giving your kids greater"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" safety on the trails."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"used"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Eva"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Eva 291"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">3400</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"The sister company to Nord, Eva launched in 2005 as the"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" first and only women-dedicated bicycle brand. Designed"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" by women for women, allEva bikes are optimized for the"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" feminine physique using analytics from a body metrics"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" database. If you like 29ers, try the Eva 291. Itβs a "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"brand new bike for 2022.. This full-suspension, "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"cross-country ride has been designed for velocity. The"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" 291 has 100mm of front and rear travel, a superlight "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"aluminum frame and fast-rolling 29-inch wheels. Yippee!"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"used"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Noka Bikes"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Kahuna"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">3200</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"Whether you want to try your hand at XC racing or are "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"looking for a lively trail bike that's just as inspiring"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" on the climbs as it is over rougher ground, the Wilder"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" is one heck of a bike built specifically for short women."</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" Both the frames and components have been tweaked to "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"include a womenβs saddle, different bars and unique "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"colourway."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"used"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Breakout"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"XBN 2.1 Alloy"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">810</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"The XBN 2.1 Alloy is our entry-level road bike β but thatβs"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" not to say that itβs a basic machine. With an internal "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"weld aluminium frame, a full carbon fork, and the slick-shifting"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" Claris gears from Shimanoβs, this is a bike which doesnβt"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" break the bank and delivers craved performance."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"new"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"ScramBikes"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"WattBike"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">2300</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"The WattBike is the best e-bike for people who still feel young"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" at heart. It has a Bafang 1000W mid-drive system and a 48V"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" 17.5AH Samsung Lithium-Ion battery, allowing you to ride for"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" more than 60 miles on one charge. Itβs great for tackling hilly"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" terrain or if you just fancy a more leisurely ride. With three"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" working modes, you can choose between E-bike, assisted bicycle,"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" and normal bike modes."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"new"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Peaknetic"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Secto"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">430</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"If you struggle with stiff fingers or a kinked neck or back after"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" a few minutes on the road, this lightweight, aluminum bike"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" alleviates those issues and allows you to enjoy the ride. From"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" the ergonomic grips to the lumbar-supporting seat position, the"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" Roll Low-Entry offers incredible comfort. The rear-inclined seat"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" tube facilitates stability by allowing you to put a foot on the"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" ground to balance at a stop, and the low step-over frame makes it"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" accessible for all ability and mobility levels. The saddle is"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" very soft, with a wide back to support your hip joints and a"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" cutout in the center to redistribute that pressure. Rim brakes"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" deliver satisfactory braking control, and the wide tires provide"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" a smooth, stable ride on paved roads and gravel. Rack and fender"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" mounts facilitate setting up the Roll Low-Entry as your preferred"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" commuter, and the BMX-like handlebar offers space for mounting a"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" flashlight, bell, or phone holder."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"new"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"nHill"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Summit"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">1200</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"This budget mountain bike from nHill performs well both on bike"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" paths and on the trail. The fork with 100mm of travel absorbs"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" rough terrain. Fat Kenda Booster tires give you grip in corners"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" and on wet trails. The Shimano Tourney drivetrain offered enough"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" gears for finding a comfortable pace to ride uphill, and the"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" Tektro hydraulic disc brakes break smoothly. Whether you want an"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" affordable bike that you can take to work, but also take trail in"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" mountains on the weekends or youβre just after a stable,"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" comfortable ride for the bike path, the Summit gives a good value"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" for money."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"new"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"ThrillCycle"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"BikeShind"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">815</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"An artsy, retro-inspired bicycle thatβs as functional as it is"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" pretty: The ThrillCycle steel frame offers a smooth ride. A"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" 9-speed drivetrain has enough gears for coasting in the city, but"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" we wouldnβt suggest taking it to the mountains. Fenders protect"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" you from mud, and a rear basket lets you transport groceries,"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" flowers and books. The ThrillCycle comes with a limited lifetime"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" warranty, so this little guy will last you long past graduation."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"refurbished"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span 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">for</span> <span class="p">(</span><span class="kt">var</span> <span class="n">i</span> <span class="p">=</span> <span class="m">0</span><span class="p">;</span> <span class="n">i</span> <span class="p"><</span> <span class="n">bicycles</span><span class="p">.</span><span class="n">Length</span><span class="p">;</span> <span class="n">i</span><span class="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">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">$"bicycle:{i}"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">bicycles</span><span class="p">[</span><span class="n">i</span><span class="p">]);</span>
</span></span><span class="line"><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="n">SearchResult</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:bicycle"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"@description: kids"</span><span class="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">res1</span><span class="p">);</span> <span class="c1">// >>> 2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'ft1' 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">SearchResult</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:bicycle"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"@model: ka*"</span><span class="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">res2</span><span class="p">.</span><span class="n">TotalResults</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="c1">// Tests for 'ft2' 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">SearchResult</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"idx:bicycle"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"@brand: *bikes"</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="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="n">TotalResults</span><span class="p">);</span> <span class="c1">// >>> 2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'ft3' 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">SearchResult</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:bicycle"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"%optamized%"</span><span class="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">res4</span><span class="p">.</span><span class="n">TotalResults</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="c1">// Tests for 'ft4' 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">SearchResult</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:bicycle"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"%%optamised%%"</span><span class="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">res5</span><span class="p">.</span><span class="n">TotalResults</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="c1">// Tests for 'ft5' 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_query_ft-stepft3')" 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_query_ft-stepft3" 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/QueryFtExample.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="fuzzy-search">
Fuzzy search
</h2>
<p>
A fuzzy search allows you to find documents with words that approximately match your search term. To perform a fuzzy search, you wrap search terms with pairs of
<code>
%
</code>
characters. A single pair represents a (Levenshtein) distance of one, two pairs represent a distance of two, and three pairs, the maximum distance, represents a distance of three.
</p>
<p>
Here is the command that searches across all text fields with a distance of one:
</p>
<pre tabindex="0"><code>FT.SEARCH index "%word%"
</code></pre>
<p>
The following example finds all documents that contain a word that has a distance of one to the incorrectly spelled word 'optamized'. You can see that this matches the word 'optimized'.
</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="query_ft-stepft4">
<input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_query_ft-stepft4" name="query_ft-stepft4" 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_query_ft-stepft4" title="Open example">
>_ Redis CLI
</label>
<div aria-labelledby="tab-query_ft-stepft4" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_query_ft-stepft4" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">FT.SEARCH idx:bicycle "%optamized%"</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_query_ft-stepft4')" 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_query_ft-stepft4" name="query_ft-stepft4" 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_query_ft-stepft4" title="Open example">
Python
</label>
<div aria-labelledby="tab-query_ft-stepft4" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_query_ft-stepft4" 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="kn">import</span> <span class="nn">json</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">sys</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 class="kn">from</span> <span class="nn">redis.commands.json.path</span> <span class="kn">import</span> <span class="n">Path</span>
</span></span><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redis.commands.search.field</span> <span class="kn">import</span> <span class="n">TextField</span><span class="p">,</span> <span class="n">NumericField</span><span class="p">,</span> <span class="n">TagField</span>
</span></span><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redis.commands.search.indexDefinition</span> <span class="kn">import</span> <span class="n">IndexDefinition</span><span class="p">,</span> <span class="n">IndexType</span>
</span></span><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redis.commands.search.query</span> <span class="kn">import</span> <span class="n">NumericFilter</span><span class="p">,</span> <span class="n">Query</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 class="c1"># create index</span>
</span></span><span class="line"><span class="cl"><span class="n">schema</span> <span class="o">=</span> <span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="n">TextField</span><span class="p">(</span><span class="s2">"$.brand"</span><span class="p">,</span> <span class="n">as_name</span><span class="o">=</span><span class="s2">"brand"</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">TextField</span><span class="p">(</span><span class="s2">"$.model"</span><span class="p">,</span> <span class="n">as_name</span><span class="o">=</span><span class="s2">"model"</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">TextField</span><span class="p">(</span><span class="s2">"$.description"</span><span class="p">,</span> <span class="n">as_name</span><span class="o">=</span><span class="s2">"description"</span><span class="p">),</span>
</span></span><span class="line"><span 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">index</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ft</span><span class="p">(</span><span class="s2">"idx:bicycle"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">index</span><span class="o">.</span><span class="n">create_index</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="n">schema</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">definition</span><span class="o">=</span><span class="n">IndexDefinition</span><span class="p">(</span><span class="n">prefix</span><span class="o">=</span><span class="p">[</span><span class="s2">"bicycle:"</span><span class="p">],</span> <span class="n">index_type</span><span class="o">=</span><span class="n">IndexType</span><span class="o">.</span><span class="n">JSON</span><span class="p">),</span>
</span></span><span class="line"><span 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"># load data</span>
</span></span><span class="line"><span class="cl"><span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s2">"data/query_em.json"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
</span></span><span class="line"><span class="cl"> <span class="n">bicycles</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">pipeline</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">pipeline</span><span class="p">(</span><span class="n">transaction</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="k">for</span> <span class="n">bid</span><span class="p">,</span> <span class="n">bicycle</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">bicycles</span><span class="p">):</span>
</span></span><span class="line"><span class="cl"> <span class="n">pipeline</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="sa">f</span><span class="s1">'bicycle:</span><span class="si">{</span><span class="n">bid</span><span class="si">}</span><span class="s1">'</span><span class="p">,</span> <span class="n">Path</span><span class="o">.</span><span class="n">root_path</span><span class="p">(),</span> <span class="n">bicycle</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">pipeline</span><span class="o">.</span><span class="n">execute</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">Query</span><span class="p">(</span><span class="s2">"@description: kids"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="o">.</span><span class="n">total</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> 2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">Query</span><span class="p">(</span><span class="s2">"@model: ka*"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="o">.</span><span class="n">total</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> 1</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">Query</span><span class="p">(</span><span class="s2">"@brand: *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">res</span><span class="o">.</span><span class="n">total</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> 2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">Query</span><span class="p">(</span><span class="s2">"</span><span class="si">%o</span><span class="s2">ptamized%"</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"># >>> Result{1 total, docs: [Document {'id': 'bicycle:3', 'payload': None, 'json': '{"pickup_zone":"POLYGON((-80.2433 25.8067, -80.1333 25.8067, -80.1333 25.6967, -80.2433 25.6967, -80.2433 25.8067))","store_location":"-80.1918,25.7617","brand":"Eva","model":"Eva 291","price":3400,"description":"The sister company to Nord, Eva launched in 2005 as the first and only women-dedicated bicycle brand. Designed by women for women, allEva bikes are optimized for the feminine physique using analytics from a body metrics database. If you like 29ers, try the Eva 291. Itβs a brand new bike for 2022.. This full-suspension, cross-country ride has been designed for velocity. The 291 has 100mm of front and rear travel, a superlight aluminum frame and fast-rolling 29-inch wheels. Yippee!","condition":"used"}'}]}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">Query</span><span class="p">(</span><span class="s2">"</span><span class="si">%%</span><span class="s2">optamised</span><span class="si">%%</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">res</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> Result{1 total, docs: [Document {'id': 'bicycle:3', 'payload': None, 'json': '{"pickup_zone":"POLYGON((-80.2433 25.8067, -80.1333 25.8067, -80.1333 25.6967, -80.2433 25.6967, -80.2433 25.8067))","store_location":"-80.1918,25.7617","brand":"Eva","model":"Eva 291","price":3400,"description":"The sister company to Nord, Eva launched in 2005 as the first and only women-dedicated bicycle brand. Designed by women for women, allEva bikes are optimized for the feminine physique using analytics from a body metrics database. If you like 29ers, try the Eva 291. Itβs a brand new bike for 2022.. This full-suspension, cross-country ride has been designed for velocity. The 291 has 100mm of front and rear travel, a superlight aluminum frame and fast-rolling 29-inch wheels. Yippee!","condition":"used"}'}]}</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_query_ft-stepft4')" 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_query_ft-stepft4" 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/query_ft.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_query_ft-stepft4" name="query_ft-stepft4" 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_query_ft-stepft4" title="Open example">
Node.js
</label>
<div aria-labelledby="tab-query_ft-stepft4" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_query_ft-stepft4" 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">'node:assert'</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">fs</span> <span class="nx">from</span> <span class="s1">'node:fs'</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">SchemaFieldTypes</span><span class="p">,</span> <span class="nx">AggregateGroupByReducers</span><span class="p">,</span> <span class="nx">AggregateSteps</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="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"><span class="cl"><span class="c1">// create index
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ft</span><span class="p">.</span><span class="nx">create</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="s1">'$.model'</span><span class="o">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">type</span><span class="o">:</span> <span class="nx">SchemaFieldTypes</span><span class="p">.</span><span class="nx">TEXT</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">AS</span><span class="o">:</span> <span class="s1">'model'</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="s1">'$.brand'</span><span class="o">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">type</span><span class="o">:</span> <span class="nx">SchemaFieldTypes</span><span class="p">.</span><span class="nx">TEXT</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">AS</span><span class="o">:</span> <span class="s1">'brand'</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="s1">'$.description'</span><span class="o">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">type</span><span class="o">:</span> <span class="nx">SchemaFieldTypes</span><span class="p">.</span><span class="nx">TEXT</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">AS</span><span class="o">:</span> <span class="s1">'description'</span>
</span></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="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ON</span><span class="o">:</span> <span class="s1">'JSON'</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">PREFIX</span><span class="o">:</span> <span class="s1">'bicycle:'</span>
</span></span><span class="line"><span 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">// load data
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">bicycles</span> <span class="o">=</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">fs</span><span class="p">.</span><span class="nx">readFileSync</span><span class="p">(</span><span class="s1">'data/query_em.json'</span><span class="p">,</span> <span class="s1">'utf8'</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="nb">Promise</span><span class="p">.</span><span class="nx">all</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="nx">bicycles</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">bicycle</span><span class="p">,</span> <span class="nx">bid</span><span class="p">)</span> <span class="p">=></span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">return</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="sb">`bicycle:</span><span class="si">${</span><span class="nx">bid</span><span class="si">}</span><span class="sb">`</span><span class="p">,</span> <span class="s1">'$'</span><span class="p">,</span> <span class="nx">bicycle</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="p">})</span>
</span></span><span class="line"><span 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">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ft</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="s1">'@description: kids'</span><span class="p">);</span>
</span></span><span class="line"><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="nx">total</span><span class="p">);</span> <span class="c1">// >>> 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">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ft</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="s1">'@model: ka*'</span><span class="p">);</span>
</span></span><span class="line"><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="nx">total</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">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ft</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="s1">'@brand: *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">res3</span><span class="p">.</span><span class="nx">total</span><span class="p">);</span> <span class="c1">// >>> 2
</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">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ft</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="s1">'%optamized%'</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">// >>> { total: 1, documents: [ { id: 'bicycle:3', value: [Object: null prototype] } ]}
</span></span></span><span class="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">ft</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="s1">'%%optamised%%'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> { total: 1, documents: [ { id: 'bicycle:3', value: [Object: null prototype] } ]}
</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_query_ft-stepft4')" 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_query_ft-stepft4" 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/query-ft.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_query_ft-stepft4" name="query_ft-stepft4" 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_query_ft-stepft4" title="Open example">
Java
</label>
<div aria-labelledby="tab-query_ft-stepft4" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_query_ft-stepft4" 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">java.util.List</span><span class="o">;</span>
</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 class="kn">import</span> <span class="nn">redis.clients.jedis.search.*</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.search.schemafields.*</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.exceptions.JedisDataException</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="kd">public</span> <span class="kd">class</span> <span class="nc">QueryFtExample</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">SchemaField</span><span class="o">[]</span> <span class="n">schema</span> <span class="o">=</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">TextField</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="s">"$.brand"</span><span class="o">).</span><span class="na">as</span><span class="o">(</span><span class="s">"brand"</span><span class="o">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">TextField</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="s">"$.model"</span><span class="o">).</span><span class="na">as</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">TextField</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="s">"$.description"</span><span class="o">).</span><span class="na">as</span><span class="o">(</span><span class="s">"description"</span><span class="o">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">NumericField</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="s">"$.price"</span><span class="o">).</span><span class="na">as</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">TagField</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="s">"$.condition"</span><span class="o">).</span><span class="na">as</span><span class="o">(</span><span class="s">"condition"</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></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">ftCreate</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">FTCreateParams</span><span class="o">.</span><span class="na">createParams</span><span class="o">()</span>
</span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">on</span><span class="o">(</span><span class="n">IndexDataType</span><span class="o">.</span><span class="na">JSON</span><span class="o">)</span>
</span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">addPrefix</span><span class="o">(</span><span class="s">"bicycle:"</span><span class="o">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">schema</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">String</span><span class="o">[]</span> <span class="n">bicycleJsons</span> <span class="o">=</span> <span class="k">new</span> <span class="n">String</span><span class="o">[]</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-74.0610 40.7578, -73.9510 40.7578, -73.9510 40.6678, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-74.0610 40.6678, -74.0610 40.7578))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-74.0060,40.7128\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Velorim\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Jigger\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 270,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"Small and powerful, the Jigger is the best ride for the smallest of tikes! "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"This is the tiniest kidsβ pedal bike on the market available without a coaster brake, the Jigger "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"is the vehicle of choice for the rare tenacious little rider raring to go.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"new\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-118.2887 34.0972, -118.1987 34.0972, -118.1987 33.9872, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-118.2887 33.9872, -118.2887 34.0972))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-118.2437,34.0522\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Bicyk\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Hillcraft\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1200,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"Kids want to ride with as little weight as possible. Especially "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"on an incline! They may be at the age when a 27.5'' wheel bike is just too clumsy coming "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"off a 24'' bike. The Hillcraft 26 is just the solution they need!\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"used\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-87.6848 41.9331, -87.5748 41.9331, -87.5748 41.8231, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-87.6848 41.8231, -87.6848 41.9331))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-87.6298,41.8781\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Nord\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Chook air 5\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 815,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"The Chook Air 5 gives kids aged six years and older a durable "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and uberlight mountain bike for their first experience on tracks and easy cruising through "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"forests and fields. The lower top tube makes it easy to mount and dismount in any "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"situation, giving your kids greater safety on the trails.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"used\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-80.2433 25.8067, -80.1333 25.8067, -80.1333 25.6967, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-80.2433 25.6967, -80.2433 25.8067))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-80.1918,25.7617\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Eva\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Eva 291\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3400,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"The sister company to Nord, Eva launched in 2005 as the first "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and only women-dedicated bicycle brand. Designed by women for women, allEva bikes "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"are optimized for the feminine physique using analytics from a body metrics database. "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"If you like 29ers, try the Eva 291. Itβs a brand new bike for 2022.. This "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"full-suspension, cross-country ride has been designed for velocity. The 291 has "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"100mm of front and rear travel, a superlight aluminum frame and fast-rolling "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"29-inch wheels. Yippee!\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"used\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-122.4644 37.8199, -122.3544 37.8199, -122.3544 37.7099, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-122.4644 37.7099, -122.4644 37.8199))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-122.4194,37.7749\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Noka Bikes\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Kahuna\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3200,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"Whether you want to try your hand at XC racing or are looking "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"for a lively trail bike that's just as inspiring on the climbs as it is over rougher "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"ground, the Wilder is one heck of a bike built specifically for short women. Both the "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"frames and components have been tweaked to include a womenβs saddle, different bars "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and unique colourway.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"used\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-0.1778 51.5524, 0.0822 51.5524, 0.0822 51.4024, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-0.1778 51.4024, -0.1778 51.5524))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-0.1278,51.5074\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Breakout\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"XBN 2.1 Alloy\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 810,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"The XBN 2.1 Alloy is our entry-level road bike β but thatβs "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"not to say that itβs a basic machine. With an internal weld aluminium frame, a full "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"carbon fork, and the slick-shifting Claris gears from Shimanoβs, this is a bike which "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"doesnβt break the bank and delivers craved performance.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"new\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((2.1767 48.9016, 2.5267 48.9016, 2.5267 48.5516, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"2.1767 48.5516, 2.1767 48.9016))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"2.3522,48.8566\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"ScramBikes\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"WattBike\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 2300,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"The WattBike is the best e-bike for people who still "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"feel young at heart. It has a Bafang 1000W mid-drive system and a 48V 17.5AH "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"Samsung Lithium-Ion battery, allowing you to ride for more than 60 miles on one "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"charge. Itβs great for tackling hilly terrain or if you just fancy a more "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"leisurely ride. With three working modes, you can choose between E-bike, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"assisted bicycle, and normal bike modes.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"new\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((13.3260 52.5700, 13.6550 52.5700, 13.6550 52.2700, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"13.3260 52.2700, 13.3260 52.5700))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"13.4050,52.5200\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Peaknetic\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Secto\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 430,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"If you struggle with stiff fingers or a kinked neck or "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"back after a few minutes on the road, this lightweight, aluminum bike alleviates "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"those issues and allows you to enjoy the ride. From the ergonomic grips to the "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"lumbar-supporting seat position, the Roll Low-Entry offers incredible comfort. "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"The rear-inclined seat tube facilitates stability by allowing you to put a foot "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"on the ground to balance at a stop, and the low step-over frame makes it "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"accessible for all ability and mobility levels. The saddle is very soft, with "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"a wide back to support your hip joints and a cutout in the center to redistribute "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"that pressure. Rim brakes deliver satisfactory braking control, and the wide tires "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"provide a smooth, stable ride on paved roads and gravel. Rack and fender mounts "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"facilitate setting up the Roll Low-Entry as your preferred commuter, and the "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"BMX-like handlebar offers space for mounting a flashlight, bell, or phone holder.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"new\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((1.9450 41.4301, 2.4018 41.4301, 2.4018 41.1987, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"1.9450 41.1987, 1.9450 41.4301))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"2.1734, 41.3851\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"nHill\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Summit\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1200,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This budget mountain bike from nHill performs well both "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"on bike paths and on the trail. The fork with 100mm of travel absorbs rough "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"terrain. Fat Kenda Booster tires give you grip in corners and on wet trails. "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"The Shimano Tourney drivetrain offered enough gears for finding a comfortable "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"pace to ride uphill, and the Tektro hydraulic disc brakes break smoothly. "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"Whether you want an affordable bike that you can take to work, but also take "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"trail in mountains on the weekends or youβre just after a stable, comfortable "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"ride for the bike path, the Summit gives a good value for money.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"new\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((12.4464 42.1028, 12.5464 42.1028, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"12.5464 41.7028, 12.4464 41.7028, 12.4464 42.1028))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"12.4964,41.9028\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"ThrillCycle\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"BikeShind\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 815,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"An artsy, retro-inspired bicycle thatβs as "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"functional as it is pretty: The ThrillCycle steel frame offers a smooth ride. "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"A 9-speed drivetrain has enough gears for coasting in the city, but we wouldnβt "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"suggest taking it to the mountains. Fenders protect you from mud, and a rear "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"basket lets you transport groceries, flowers and books. The ThrillCycle comes "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"with a limited lifetime warranty, so this little guy will last you long "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"past graduation.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"refurbished\""</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></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">bicycleJsons</span><span class="o">.</span><span class="na">length</span><span class="o">;</span> <span class="n">i</span><span class="o">++)</span> <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 class="s">"bicycle:"</span> <span class="o">+</span> <span class="n">i</span><span class="o">,</span> <span class="n">Path2</span><span class="o">.</span><span class="na">ROOT_PATH</span><span class="o">,</span> <span class="n">bicycleJsons</span><span class="o">[</span><span class="n">i</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></span><span class="line"><span class="cl"> <span class="n">SearchResult</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ftSearch</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span> <span class="s">"@description: kids"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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="na">getTotalResults</span><span class="o">());</span> <span class="c1">// >>> 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"><</span><span class="n">Document</span><span class="o">></span> <span class="n">docs1</span> <span class="o">=</span> <span class="n">res1</span><span class="o">.</span><span class="na">getDocuments</span><span class="o">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">docs1</span><span class="o">.</span><span class="na">size</span><span class="o">();</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">docs1</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">getId</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="c1">// >>> bicycle:2
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// >>> bicycle:1
</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 'ft1' 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">SearchResult</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ftSearch</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span> <span class="s">"@model: ka*"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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="na">getTotalResults</span><span class="o">());</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="n">List</span><span class="o"><</span><span class="n">Document</span><span class="o">></span> <span class="n">docs2</span> <span class="o">=</span> <span class="n">res2</span><span class="o">.</span><span class="na">getDocuments</span><span class="o">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">docs2</span><span class="o">.</span><span class="na">size</span><span class="o">();</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">docs2</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">getId</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="c1">// >>> bicycle:4
</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 'ft2' 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">SearchResult</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ftSearch</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span> <span class="s">"@brand: *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">res3</span><span class="o">.</span><span class="na">getTotalResults</span><span class="o">());</span> <span class="c1">// >>> 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"><</span><span class="n">Document</span><span class="o">></span> <span class="n">docs3</span> <span class="o">=</span> <span class="n">res3</span><span class="o">.</span><span class="na">getDocuments</span><span class="o">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">docs3</span><span class="o">.</span><span class="na">size</span><span class="o">();</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">docs3</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">getId</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="c1">// >>> bicycle:6
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// >>> bicycle:4
</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 'ft3' 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">SearchResult</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ftSearch</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span> <span class="s">"%optamized%"</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="na">getTotalResults</span><span class="o">());</span> <span class="c1">// >>> 1
</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"><</span><span class="n">Document</span><span class="o">></span> <span class="n">docs4</span> <span class="o">=</span> <span class="n">res4</span><span class="o">.</span><span class="na">getDocuments</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">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">docs4</span><span class="o">.</span><span class="na">size</span><span class="o">();</span> <span class="n">i</span><span class="o">++)</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">docs4</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">getId</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="c1">// >>> bicycle:3
</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 'ft4' 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">SearchResult</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ftSearch</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span> <span class="s">"%%optamised%%"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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="na">getTotalResults</span><span class="o">());</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="n">List</span><span class="o"><</span><span class="n">Document</span><span class="o">></span> <span class="n">docs5</span> <span class="o">=</span> <span class="n">res5</span><span class="o">.</span><span class="na">getDocuments</span><span class="o">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">docs5</span><span class="o">.</span><span class="na">size</span><span class="o">();</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">docs5</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">getId</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="c1">// >>> bicycle:3
</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 'ft5' 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_query_ft-stepft4')" 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_query_ft-stepft4" 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/QueryFtExample.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="dotnet" id="Csharp_query_ft-stepft4" name="query_ft-stepft4" 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_query_ft-stepft4" title="Open example">
C#
</label>
<div aria-labelledby="tab-query_ft-stepft4" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_query_ft-stepft4" 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.Search</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Search.Literals.Enums</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">QueryFtExample</span>
</span></span><span class="line"><span 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 class="n">Schema</span> <span class="n">bikeSchema</span> <span class="p">=</span> <span class="k">new</span> <span class="n">Schema</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddTextField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.brand"</span><span class="p">,</span> <span class="s">"brand"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddTextField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.model"</span><span class="p">,</span> <span class="s">"model"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddTextField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.description"</span><span class="p">,</span> <span class="s">"description"</span><span class="p">));</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">FTCreateParams</span> <span class="n">bikeParams</span> <span class="p">=</span> <span class="k">new</span> <span class="n">FTCreateParams</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddPrefix</span><span class="p">(</span><span class="s">"bicycle:"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">On</span><span class="p">(</span><span class="n">IndexDataType</span><span class="p">.</span><span class="n">JSON</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Create</span><span class="p">(</span><span class="s">"idx:bicycle"</span><span class="p">,</span> <span class="n">bikeParams</span><span class="p">,</span> <span class="n">bikeSchema</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">bicycles</span> <span class="p">=</span> <span class="k">new</span> <span class="kt">object</span><span class="p">[]</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Velorim"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Jigger"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">270</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"Small and powerful, the Jigger is the best ride "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"for the smallest of tikes! This is the tiniest "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"kidsβ pedal bike on the market available without"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" a coaster brake, the Jigger is the vehicle of "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"choice for the rare tenacious little rider "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"raring to go."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"used"</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Bicyk"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Hillcraft"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">1200</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"Kids want to ride with as little weight as possible."</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" Especially on an incline! They may be at the age "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"when a 27.5 inch wheel bike is just too clumsy coming "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"off a 24 inch bike. The Hillcraft 26 is just the solution"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" they need!"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"used"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Nord"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Chook air 5"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">815</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"The Chook Air 5 gives kids aged six years and older "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"a durable and uberlight mountain bike for their first"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" experience on tracks and easy cruising through forests"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" and fields. The lower top tube makes it easy to mount"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" and dismount in any situation, giving your kids greater"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" safety on the trails."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"used"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Eva"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Eva 291"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">3400</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"The sister company to Nord, Eva launched in 2005 as the"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" first and only women-dedicated bicycle brand. Designed"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" by women for women, allEva bikes are optimized for the"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" feminine physique using analytics from a body metrics"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" database. If you like 29ers, try the Eva 291. Itβs a "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"brand new bike for 2022.. This full-suspension, "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"cross-country ride has been designed for velocity. The"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" 291 has 100mm of front and rear travel, a superlight "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"aluminum frame and fast-rolling 29-inch wheels. Yippee!"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"used"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Noka Bikes"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Kahuna"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">3200</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"Whether you want to try your hand at XC racing or are "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"looking for a lively trail bike that's just as inspiring"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" on the climbs as it is over rougher ground, the Wilder"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" is one heck of a bike built specifically for short women."</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" Both the frames and components have been tweaked to "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"include a womenβs saddle, different bars and unique "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"colourway."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"used"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Breakout"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"XBN 2.1 Alloy"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">810</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"The XBN 2.1 Alloy is our entry-level road bike β but thatβs"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" not to say that itβs a basic machine. With an internal "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"weld aluminium frame, a full carbon fork, and the slick-shifting"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" Claris gears from Shimanoβs, this is a bike which doesnβt"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" break the bank and delivers craved performance."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"new"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"ScramBikes"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"WattBike"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">2300</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"The WattBike is the best e-bike for people who still feel young"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" at heart. It has a Bafang 1000W mid-drive system and a 48V"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" 17.5AH Samsung Lithium-Ion battery, allowing you to ride for"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" more than 60 miles on one charge. Itβs great for tackling hilly"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" terrain or if you just fancy a more leisurely ride. With three"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" working modes, you can choose between E-bike, assisted bicycle,"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" and normal bike modes."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"new"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Peaknetic"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Secto"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">430</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"If you struggle with stiff fingers or a kinked neck or back after"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" a few minutes on the road, this lightweight, aluminum bike"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" alleviates those issues and allows you to enjoy the ride. From"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" the ergonomic grips to the lumbar-supporting seat position, the"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" Roll Low-Entry offers incredible comfort. The rear-inclined seat"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" tube facilitates stability by allowing you to put a foot on the"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" ground to balance at a stop, and the low step-over frame makes it"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" accessible for all ability and mobility levels. The saddle is"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" very soft, with a wide back to support your hip joints and a"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" cutout in the center to redistribute that pressure. Rim brakes"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" deliver satisfactory braking control, and the wide tires provide"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" a smooth, stable ride on paved roads and gravel. Rack and fender"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" mounts facilitate setting up the Roll Low-Entry as your preferred"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" commuter, and the BMX-like handlebar offers space for mounting a"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" flashlight, bell, or phone holder."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"new"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"nHill"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Summit"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">1200</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"This budget mountain bike from nHill performs well both on bike"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" paths and on the trail. The fork with 100mm of travel absorbs"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" rough terrain. Fat Kenda Booster tires give you grip in corners"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" and on wet trails. The Shimano Tourney drivetrain offered enough"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" gears for finding a comfortable pace to ride uphill, and the"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" Tektro hydraulic disc brakes break smoothly. Whether you want an"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" affordable bike that you can take to work, but also take trail in"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" mountains on the weekends or youβre just after a stable,"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" comfortable ride for the bike path, the Summit gives a good value"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" for money."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"new"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"ThrillCycle"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"BikeShind"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">815</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"An artsy, retro-inspired bicycle thatβs as functional as it is"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" pretty: The ThrillCycle steel frame offers a smooth ride. A"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" 9-speed drivetrain has enough gears for coasting in the city, but"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" we wouldnβt suggest taking it to the mountains. Fenders protect"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" you from mud, and a rear basket lets you transport groceries,"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" flowers and books. The ThrillCycle comes with a limited lifetime"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" warranty, so this little guy will last you long past graduation."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"refurbished"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span 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">for</span> <span class="p">(</span><span class="kt">var</span> <span class="n">i</span> <span class="p">=</span> <span class="m">0</span><span class="p">;</span> <span class="n">i</span> <span class="p"><</span> <span class="n">bicycles</span><span class="p">.</span><span class="n">Length</span><span class="p">;</span> <span class="n">i</span><span class="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">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">$"bicycle:{i}"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">bicycles</span><span class="p">[</span><span class="n">i</span><span class="p">]);</span>
</span></span><span class="line"><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="n">SearchResult</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:bicycle"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"@description: kids"</span><span class="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">res1</span><span class="p">);</span> <span class="c1">// >>> 2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'ft1' 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">SearchResult</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:bicycle"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"@model: ka*"</span><span class="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">res2</span><span class="p">.</span><span class="n">TotalResults</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="c1">// Tests for 'ft2' 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">SearchResult</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:bicycle"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"@brand: *bikes"</span><span class="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">res3</span><span class="p">.</span><span class="n">TotalResults</span><span class="p">);</span> <span class="c1">// >>> 2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'ft3' 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">SearchResult</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"idx:bicycle"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"%optamized%"</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="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="n">TotalResults</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="c1">// Tests for 'ft4' 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">SearchResult</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:bicycle"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"%%optamised%%"</span><span class="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">res5</span><span class="p">.</span><span class="n">TotalResults</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="c1">// Tests for 'ft5' 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_query_ft-stepft4')" 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_query_ft-stepft4" 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/QueryFtExample.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>
If you want to increase the maximum word distance to two, you can use the following query:
</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="query_ft-stepft5">
<input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_query_ft-stepft5" name="query_ft-stepft5" 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_query_ft-stepft5" title="Open example">
>_ Redis CLI
</label>
<div aria-labelledby="tab-query_ft-stepft5" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_query_ft-stepft5" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">FT.SEARCH idx:bicycle "%%optamised%%"</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_query_ft-stepft5')" 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_query_ft-stepft5" name="query_ft-stepft5" 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_query_ft-stepft5" title="Open example">
Python
</label>
<div aria-labelledby="tab-query_ft-stepft5" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_query_ft-stepft5" 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="kn">import</span> <span class="nn">json</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">sys</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 class="kn">from</span> <span class="nn">redis.commands.json.path</span> <span class="kn">import</span> <span class="n">Path</span>
</span></span><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redis.commands.search.field</span> <span class="kn">import</span> <span class="n">TextField</span><span class="p">,</span> <span class="n">NumericField</span><span class="p">,</span> <span class="n">TagField</span>
</span></span><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redis.commands.search.indexDefinition</span> <span class="kn">import</span> <span class="n">IndexDefinition</span><span class="p">,</span> <span class="n">IndexType</span>
</span></span><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redis.commands.search.query</span> <span class="kn">import</span> <span class="n">NumericFilter</span><span class="p">,</span> <span class="n">Query</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 class="c1"># create index</span>
</span></span><span class="line"><span class="cl"><span class="n">schema</span> <span class="o">=</span> <span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="n">TextField</span><span class="p">(</span><span class="s2">"$.brand"</span><span class="p">,</span> <span class="n">as_name</span><span class="o">=</span><span class="s2">"brand"</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">TextField</span><span class="p">(</span><span class="s2">"$.model"</span><span class="p">,</span> <span class="n">as_name</span><span class="o">=</span><span class="s2">"model"</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">TextField</span><span class="p">(</span><span class="s2">"$.description"</span><span class="p">,</span> <span class="n">as_name</span><span class="o">=</span><span class="s2">"description"</span><span class="p">),</span>
</span></span><span class="line"><span 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">index</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ft</span><span class="p">(</span><span class="s2">"idx:bicycle"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">index</span><span class="o">.</span><span class="n">create_index</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="n">schema</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">definition</span><span class="o">=</span><span class="n">IndexDefinition</span><span class="p">(</span><span class="n">prefix</span><span class="o">=</span><span class="p">[</span><span class="s2">"bicycle:"</span><span class="p">],</span> <span class="n">index_type</span><span class="o">=</span><span class="n">IndexType</span><span class="o">.</span><span class="n">JSON</span><span class="p">),</span>
</span></span><span class="line"><span 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"># load data</span>
</span></span><span class="line"><span class="cl"><span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s2">"data/query_em.json"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
</span></span><span class="line"><span class="cl"> <span class="n">bicycles</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">pipeline</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">pipeline</span><span class="p">(</span><span class="n">transaction</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="k">for</span> <span class="n">bid</span><span class="p">,</span> <span class="n">bicycle</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">bicycles</span><span class="p">):</span>
</span></span><span class="line"><span class="cl"> <span class="n">pipeline</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="sa">f</span><span class="s1">'bicycle:</span><span class="si">{</span><span class="n">bid</span><span class="si">}</span><span class="s1">'</span><span class="p">,</span> <span class="n">Path</span><span class="o">.</span><span class="n">root_path</span><span class="p">(),</span> <span class="n">bicycle</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">pipeline</span><span class="o">.</span><span class="n">execute</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">Query</span><span class="p">(</span><span class="s2">"@description: kids"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="o">.</span><span class="n">total</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> 2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">Query</span><span class="p">(</span><span class="s2">"@model: ka*"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="o">.</span><span class="n">total</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> 1</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">Query</span><span class="p">(</span><span class="s2">"@brand: *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">res</span><span class="o">.</span><span class="n">total</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> 2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">Query</span><span class="p">(</span><span class="s2">"</span><span class="si">%o</span><span class="s2">ptamized%"</span><span class="p">))</span>
</span></span><span class="line"><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"><span class="cl"><span class="c1"># >>> Result{1 total, docs: [Document {'id': 'bicycle:3', 'payload': None, 'json': '{"pickup_zone":"POLYGON((-80.2433 25.8067, -80.1333 25.8067, -80.1333 25.6967, -80.2433 25.6967, -80.2433 25.8067))","store_location":"-80.1918,25.7617","brand":"Eva","model":"Eva 291","price":3400,"description":"The sister company to Nord, Eva launched in 2005 as the first and only women-dedicated bicycle brand. Designed by women for women, allEva bikes are optimized for the feminine physique using analytics from a body metrics database. If you like 29ers, try the Eva 291. Itβs a brand new bike for 2022.. This full-suspension, cross-country ride has been designed for velocity. The 291 has 100mm of front and rear travel, a superlight aluminum frame and fast-rolling 29-inch wheels. Yippee!","condition":"used"}'}]}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">Query</span><span class="p">(</span><span class="s2">"</span><span class="si">%%</span><span class="s2">optamised</span><span class="si">%%</span><span class="s2">"</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"># >>> Result{1 total, docs: [Document {'id': 'bicycle:3', 'payload': None, 'json': '{"pickup_zone":"POLYGON((-80.2433 25.8067, -80.1333 25.8067, -80.1333 25.6967, -80.2433 25.6967, -80.2433 25.8067))","store_location":"-80.1918,25.7617","brand":"Eva","model":"Eva 291","price":3400,"description":"The sister company to Nord, Eva launched in 2005 as the first and only women-dedicated bicycle brand. Designed by women for women, allEva bikes are optimized for the feminine physique using analytics from a body metrics database. If you like 29ers, try the Eva 291. Itβs a brand new bike for 2022.. This full-suspension, cross-country ride has been designed for velocity. The 291 has 100mm of front and rear travel, a superlight aluminum frame and fast-rolling 29-inch wheels. Yippee!","condition":"used"}'}]}</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_query_ft-stepft5')" 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_query_ft-stepft5" 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/query_ft.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_query_ft-stepft5" name="query_ft-stepft5" 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_query_ft-stepft5" title="Open example">
Node.js
</label>
<div aria-labelledby="tab-query_ft-stepft5" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_query_ft-stepft5" 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">'node:assert'</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">fs</span> <span class="nx">from</span> <span class="s1">'node:fs'</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">SchemaFieldTypes</span><span class="p">,</span> <span class="nx">AggregateGroupByReducers</span><span class="p">,</span> <span class="nx">AggregateSteps</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="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"><span class="cl"><span class="c1">// create index
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ft</span><span class="p">.</span><span class="nx">create</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="s1">'$.model'</span><span class="o">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">type</span><span class="o">:</span> <span class="nx">SchemaFieldTypes</span><span class="p">.</span><span class="nx">TEXT</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">AS</span><span class="o">:</span> <span class="s1">'model'</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="s1">'$.brand'</span><span class="o">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">type</span><span class="o">:</span> <span class="nx">SchemaFieldTypes</span><span class="p">.</span><span class="nx">TEXT</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">AS</span><span class="o">:</span> <span class="s1">'brand'</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="s1">'$.description'</span><span class="o">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">type</span><span class="o">:</span> <span class="nx">SchemaFieldTypes</span><span class="p">.</span><span class="nx">TEXT</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">AS</span><span class="o">:</span> <span class="s1">'description'</span>
</span></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="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ON</span><span class="o">:</span> <span class="s1">'JSON'</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">PREFIX</span><span class="o">:</span> <span class="s1">'bicycle:'</span>
</span></span><span class="line"><span 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">// load data
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">bicycles</span> <span class="o">=</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">fs</span><span class="p">.</span><span class="nx">readFileSync</span><span class="p">(</span><span class="s1">'data/query_em.json'</span><span class="p">,</span> <span class="s1">'utf8'</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="nb">Promise</span><span class="p">.</span><span class="nx">all</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="nx">bicycles</span><span class="p">.</span><span class="nx">map</span><span class="p">((</span><span class="nx">bicycle</span><span class="p">,</span> <span class="nx">bid</span><span class="p">)</span> <span class="p">=></span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">return</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="sb">`bicycle:</span><span class="si">${</span><span class="nx">bid</span><span class="si">}</span><span class="sb">`</span><span class="p">,</span> <span class="s1">'$'</span><span class="p">,</span> <span class="nx">bicycle</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="p">})</span>
</span></span><span class="line"><span 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">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ft</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="s1">'@description: kids'</span><span class="p">);</span>
</span></span><span class="line"><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="nx">total</span><span class="p">);</span> <span class="c1">// >>> 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">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ft</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="s1">'@model: ka*'</span><span class="p">);</span>
</span></span><span class="line"><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="nx">total</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">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ft</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="s1">'@brand: *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">res3</span><span class="p">.</span><span class="nx">total</span><span class="p">);</span> <span class="c1">// >>> 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">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ft</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="s1">'%optamized%'</span><span class="p">);</span>
</span></span><span class="line"><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">// >>> { total: 1, documents: [ { id: 'bicycle:3', value: [Object: null prototype] } ]}
</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">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">ft</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="s1">'idx:bicycle'</span><span class="p">,</span> <span class="s1">'%%optamised%%'</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">res5</span><span class="p">);</span> <span class="c1">// >>> { total: 1, documents: [ { id: 'bicycle:3', value: [Object: null prototype] } ]}
</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_query_ft-stepft5')" 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_query_ft-stepft5" 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/query-ft.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_query_ft-stepft5" name="query_ft-stepft5" 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_query_ft-stepft5" title="Open example">
Java
</label>
<div aria-labelledby="tab-query_ft-stepft5" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_query_ft-stepft5" 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">java.util.List</span><span class="o">;</span>
</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 class="kn">import</span> <span class="nn">redis.clients.jedis.search.*</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.search.schemafields.*</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.exceptions.JedisDataException</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="kd">public</span> <span class="kd">class</span> <span class="nc">QueryFtExample</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">SchemaField</span><span class="o">[]</span> <span class="n">schema</span> <span class="o">=</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">TextField</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="s">"$.brand"</span><span class="o">).</span><span class="na">as</span><span class="o">(</span><span class="s">"brand"</span><span class="o">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">TextField</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="s">"$.model"</span><span class="o">).</span><span class="na">as</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">TextField</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="s">"$.description"</span><span class="o">).</span><span class="na">as</span><span class="o">(</span><span class="s">"description"</span><span class="o">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">NumericField</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="s">"$.price"</span><span class="o">).</span><span class="na">as</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">TagField</span><span class="o">.</span><span class="na">of</span><span class="o">(</span><span class="s">"$.condition"</span><span class="o">).</span><span class="na">as</span><span class="o">(</span><span class="s">"condition"</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></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">ftCreate</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">FTCreateParams</span><span class="o">.</span><span class="na">createParams</span><span class="o">()</span>
</span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">on</span><span class="o">(</span><span class="n">IndexDataType</span><span class="o">.</span><span class="na">JSON</span><span class="o">)</span>
</span></span><span class="line"><span class="cl"> <span class="o">.</span><span class="na">addPrefix</span><span class="o">(</span><span class="s">"bicycle:"</span><span class="o">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">schema</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">String</span><span class="o">[]</span> <span class="n">bicycleJsons</span> <span class="o">=</span> <span class="k">new</span> <span class="n">String</span><span class="o">[]</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-74.0610 40.7578, -73.9510 40.7578, -73.9510 40.6678, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-74.0610 40.6678, -74.0610 40.7578))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-74.0060,40.7128\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Velorim\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Jigger\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 270,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"Small and powerful, the Jigger is the best ride for the smallest of tikes! "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"This is the tiniest kidsβ pedal bike on the market available without a coaster brake, the Jigger "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"is the vehicle of choice for the rare tenacious little rider raring to go.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"new\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-118.2887 34.0972, -118.1987 34.0972, -118.1987 33.9872, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-118.2887 33.9872, -118.2887 34.0972))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-118.2437,34.0522\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Bicyk\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Hillcraft\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1200,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"Kids want to ride with as little weight as possible. Especially "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"on an incline! They may be at the age when a 27.5'' wheel bike is just too clumsy coming "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"off a 24'' bike. The Hillcraft 26 is just the solution they need!\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"used\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-87.6848 41.9331, -87.5748 41.9331, -87.5748 41.8231, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-87.6848 41.8231, -87.6848 41.9331))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-87.6298,41.8781\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Nord\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Chook air 5\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 815,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"The Chook Air 5 gives kids aged six years and older a durable "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and uberlight mountain bike for their first experience on tracks and easy cruising through "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"forests and fields. The lower top tube makes it easy to mount and dismount in any "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"situation, giving your kids greater safety on the trails.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"used\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-80.2433 25.8067, -80.1333 25.8067, -80.1333 25.6967, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-80.2433 25.6967, -80.2433 25.8067))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-80.1918,25.7617\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Eva\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Eva 291\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3400,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"The sister company to Nord, Eva launched in 2005 as the first "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and only women-dedicated bicycle brand. Designed by women for women, allEva bikes "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"are optimized for the feminine physique using analytics from a body metrics database. "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"If you like 29ers, try the Eva 291. Itβs a brand new bike for 2022.. This "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"full-suspension, cross-country ride has been designed for velocity. The 291 has "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"100mm of front and rear travel, a superlight aluminum frame and fast-rolling "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"29-inch wheels. Yippee!\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"used\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-122.4644 37.8199, -122.3544 37.8199, -122.3544 37.7099, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-122.4644 37.7099, -122.4644 37.8199))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-122.4194,37.7749\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Noka Bikes\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Kahuna\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 3200,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"Whether you want to try your hand at XC racing or are looking "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"for a lively trail bike that's just as inspiring on the climbs as it is over rougher "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"ground, the Wilder is one heck of a bike built specifically for short women. Both the "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"frames and components have been tweaked to include a womenβs saddle, different bars "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"and unique colourway.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"used\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((-0.1778 51.5524, 0.0822 51.5524, 0.0822 51.4024, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"-0.1778 51.4024, -0.1778 51.5524))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"-0.1278,51.5074\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Breakout\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"XBN 2.1 Alloy\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 810,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"The XBN 2.1 Alloy is our entry-level road bike β but thatβs "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"not to say that itβs a basic machine. With an internal weld aluminium frame, a full "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"carbon fork, and the slick-shifting Claris gears from Shimanoβs, this is a bike which "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"doesnβt break the bank and delivers craved performance.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"new\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((2.1767 48.9016, 2.5267 48.9016, 2.5267 48.5516, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"2.1767 48.5516, 2.1767 48.9016))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"2.3522,48.8566\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"ScramBikes\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"WattBike\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 2300,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"The WattBike is the best e-bike for people who still "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"feel young at heart. It has a Bafang 1000W mid-drive system and a 48V 17.5AH "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"Samsung Lithium-Ion battery, allowing you to ride for more than 60 miles on one "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"charge. Itβs great for tackling hilly terrain or if you just fancy a more "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"leisurely ride. With three working modes, you can choose between E-bike, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"assisted bicycle, and normal bike modes.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"new\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((13.3260 52.5700, 13.6550 52.5700, 13.6550 52.2700, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"13.3260 52.2700, 13.3260 52.5700))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"13.4050,52.5200\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"Peaknetic\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Secto\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 430,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"If you struggle with stiff fingers or a kinked neck or "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"back after a few minutes on the road, this lightweight, aluminum bike alleviates "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"those issues and allows you to enjoy the ride. From the ergonomic grips to the "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"lumbar-supporting seat position, the Roll Low-Entry offers incredible comfort. "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"The rear-inclined seat tube facilitates stability by allowing you to put a foot "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"on the ground to balance at a stop, and the low step-over frame makes it "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"accessible for all ability and mobility levels. The saddle is very soft, with "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"a wide back to support your hip joints and a cutout in the center to redistribute "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"that pressure. Rim brakes deliver satisfactory braking control, and the wide tires "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"provide a smooth, stable ride on paved roads and gravel. Rack and fender mounts "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"facilitate setting up the Roll Low-Entry as your preferred commuter, and the "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"BMX-like handlebar offers space for mounting a flashlight, bell, or phone holder.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"new\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((1.9450 41.4301, 2.4018 41.4301, 2.4018 41.1987, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"1.9450 41.1987, 1.9450 41.4301))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"2.1734, 41.3851\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"nHill\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"Summit\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 1200,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"This budget mountain bike from nHill performs well both "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"on bike paths and on the trail. The fork with 100mm of travel absorbs rough "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"terrain. Fat Kenda Booster tires give you grip in corners and on wet trails. "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"The Shimano Tourney drivetrain offered enough gears for finding a comfortable "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"pace to ride uphill, and the Tektro hydraulic disc brakes break smoothly. "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"Whether you want an affordable bike that you can take to work, but also take "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"trail in mountains on the weekends or youβre just after a stable, comfortable "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"ride for the bike path, the Summit gives a good value for money.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"new\""</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="s">" {"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"pickup_zone\": \"POLYGON((12.4464 42.1028, 12.5464 42.1028, "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"12.5464 41.7028, 12.4464 41.7028, 12.4464 42.1028))\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"store_location\": \"12.4964,41.9028\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"model\": \"ThrillCycle\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"brand\": \"BikeShind\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"price\": 815,"</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"description\": \"An artsy, retro-inspired bicycle thatβs as "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"functional as it is pretty: The ThrillCycle steel frame offers a smooth ride. "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"A 9-speed drivetrain has enough gears for coasting in the city, but we wouldnβt "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"suggest taking it to the mountains. Fenders protect you from mud, and a rear "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"basket lets you transport groceries, flowers and books. The ThrillCycle comes "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"with a limited lifetime warranty, so this little guy will last you long "</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">"past graduation.\","</span>
</span></span><span class="line"><span class="cl"> <span class="o">+</span> <span class="s">" \"condition\": \"refurbished\""</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></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">bicycleJsons</span><span class="o">.</span><span class="na">length</span><span class="o">;</span> <span class="n">i</span><span class="o">++)</span> <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 class="s">"bicycle:"</span> <span class="o">+</span> <span class="n">i</span><span class="o">,</span> <span class="n">Path2</span><span class="o">.</span><span class="na">ROOT_PATH</span><span class="o">,</span> <span class="n">bicycleJsons</span><span class="o">[</span><span class="n">i</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></span><span class="line"><span class="cl"> <span class="n">SearchResult</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ftSearch</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span> <span class="s">"@description: kids"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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="na">getTotalResults</span><span class="o">());</span> <span class="c1">// >>> 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"><</span><span class="n">Document</span><span class="o">></span> <span class="n">docs1</span> <span class="o">=</span> <span class="n">res1</span><span class="o">.</span><span class="na">getDocuments</span><span class="o">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">docs1</span><span class="o">.</span><span class="na">size</span><span class="o">();</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">docs1</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">getId</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="c1">// >>> bicycle:2
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// >>> bicycle:1
</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 'ft1' 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">SearchResult</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ftSearch</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span> <span class="s">"@model: ka*"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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="na">getTotalResults</span><span class="o">());</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="n">List</span><span class="o"><</span><span class="n">Document</span><span class="o">></span> <span class="n">docs2</span> <span class="o">=</span> <span class="n">res2</span><span class="o">.</span><span class="na">getDocuments</span><span class="o">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">docs2</span><span class="o">.</span><span class="na">size</span><span class="o">();</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">docs2</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">getId</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="c1">// >>> bicycle:4
</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 'ft2' 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">SearchResult</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ftSearch</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span> <span class="s">"@brand: *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">res3</span><span class="o">.</span><span class="na">getTotalResults</span><span class="o">());</span> <span class="c1">// >>> 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"><</span><span class="n">Document</span><span class="o">></span> <span class="n">docs3</span> <span class="o">=</span> <span class="n">res3</span><span class="o">.</span><span class="na">getDocuments</span><span class="o">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">docs3</span><span class="o">.</span><span class="na">size</span><span class="o">();</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">docs3</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">getId</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="c1">// >>> bicycle:6
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// >>> bicycle:4
</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 'ft3' 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">SearchResult</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ftSearch</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span> <span class="s">"%optamized%"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span 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="na">getTotalResults</span><span class="o">());</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="n">List</span><span class="o"><</span><span class="n">Document</span><span class="o">></span> <span class="n">docs4</span> <span class="o">=</span> <span class="n">res4</span><span class="o">.</span><span class="na">getDocuments</span><span class="o">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">docs4</span><span class="o">.</span><span class="na">size</span><span class="o">();</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">docs4</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">getId</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="c1">// >>> bicycle:3
</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 'ft4' 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">SearchResult</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">ftSearch</span><span class="o">(</span><span class="s">"idx:bicycle"</span><span class="o">,</span> <span class="s">"%%optamised%%"</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="na">getTotalResults</span><span class="o">());</span> <span class="c1">// >>> 1
</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"><</span><span class="n">Document</span><span class="o">></span> <span class="n">docs5</span> <span class="o">=</span> <span class="n">res5</span><span class="o">.</span><span class="na">getDocuments</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">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">docs5</span><span class="o">.</span><span class="na">size</span><span class="o">();</span> <span class="n">i</span><span class="o">++)</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">docs5</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">i</span><span class="o">).</span><span class="na">getId</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="c1">// >>> bicycle:3
</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 'ft5' 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_query_ft-stepft5')" 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_query_ft-stepft5" 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/QueryFtExample.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="dotnet" id="Csharp_query_ft-stepft5" name="query_ft-stepft5" 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_query_ft-stepft5" title="Open example">
C#
</label>
<div aria-labelledby="tab-query_ft-stepft5" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_query_ft-stepft5" 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.Search</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Search.Literals.Enums</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">QueryFtExample</span>
</span></span><span class="line"><span 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 class="n">Schema</span> <span class="n">bikeSchema</span> <span class="p">=</span> <span class="k">new</span> <span class="n">Schema</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddTextField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.brand"</span><span class="p">,</span> <span class="s">"brand"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddTextField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.model"</span><span class="p">,</span> <span class="s">"model"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddTextField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.description"</span><span class="p">,</span> <span class="s">"description"</span><span class="p">));</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">FTCreateParams</span> <span class="n">bikeParams</span> <span class="p">=</span> <span class="k">new</span> <span class="n">FTCreateParams</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddPrefix</span><span class="p">(</span><span class="s">"bicycle:"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">On</span><span class="p">(</span><span class="n">IndexDataType</span><span class="p">.</span><span class="n">JSON</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Create</span><span class="p">(</span><span class="s">"idx:bicycle"</span><span class="p">,</span> <span class="n">bikeParams</span><span class="p">,</span> <span class="n">bikeSchema</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">bicycles</span> <span class="p">=</span> <span class="k">new</span> <span class="kt">object</span><span class="p">[]</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Velorim"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Jigger"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">270</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"Small and powerful, the Jigger is the best ride "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"for the smallest of tikes! This is the tiniest "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"kidsβ pedal bike on the market available without"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" a coaster brake, the Jigger is the vehicle of "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"choice for the rare tenacious little rider "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"raring to go."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"used"</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Bicyk"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Hillcraft"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">1200</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"Kids want to ride with as little weight as possible."</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" Especially on an incline! They may be at the age "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"when a 27.5 inch wheel bike is just too clumsy coming "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"off a 24 inch bike. The Hillcraft 26 is just the solution"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" they need!"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"used"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Nord"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Chook air 5"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">815</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"The Chook Air 5 gives kids aged six years and older "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"a durable and uberlight mountain bike for their first"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" experience on tracks and easy cruising through forests"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" and fields. The lower top tube makes it easy to mount"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" and dismount in any situation, giving your kids greater"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" safety on the trails."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"used"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Eva"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Eva 291"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">3400</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"The sister company to Nord, Eva launched in 2005 as the"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" first and only women-dedicated bicycle brand. Designed"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" by women for women, allEva bikes are optimized for the"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" feminine physique using analytics from a body metrics"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" database. If you like 29ers, try the Eva 291. Itβs a "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"brand new bike for 2022.. This full-suspension, "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"cross-country ride has been designed for velocity. The"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" 291 has 100mm of front and rear travel, a superlight "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"aluminum frame and fast-rolling 29-inch wheels. Yippee!"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"used"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Noka Bikes"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Kahuna"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">3200</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"Whether you want to try your hand at XC racing or are "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"looking for a lively trail bike that's just as inspiring"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" on the climbs as it is over rougher ground, the Wilder"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" is one heck of a bike built specifically for short women."</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" Both the frames and components have been tweaked to "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"include a womenβs saddle, different bars and unique "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"colourway."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"used"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Breakout"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"XBN 2.1 Alloy"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">810</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"The XBN 2.1 Alloy is our entry-level road bike β but thatβs"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" not to say that itβs a basic machine. With an internal "</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">"weld aluminium frame, a full carbon fork, and the slick-shifting"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" Claris gears from Shimanoβs, this is a bike which doesnβt"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" break the bank and delivers craved performance."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"new"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"ScramBikes"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"WattBike"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">2300</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"The WattBike is the best e-bike for people who still feel young"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" at heart. It has a Bafang 1000W mid-drive system and a 48V"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" 17.5AH Samsung Lithium-Ion battery, allowing you to ride for"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" more than 60 miles on one charge. Itβs great for tackling hilly"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" terrain or if you just fancy a more leisurely ride. With three"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" working modes, you can choose between E-bike, assisted bicycle,"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" and normal bike modes."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"new"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"Peaknetic"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Secto"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">430</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"If you struggle with stiff fingers or a kinked neck or back after"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" a few minutes on the road, this lightweight, aluminum bike"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" alleviates those issues and allows you to enjoy the ride. From"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" the ergonomic grips to the lumbar-supporting seat position, the"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" Roll Low-Entry offers incredible comfort. The rear-inclined seat"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" tube facilitates stability by allowing you to put a foot on the"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" ground to balance at a stop, and the low step-over frame makes it"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" accessible for all ability and mobility levels. The saddle is"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" very soft, with a wide back to support your hip joints and a"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" cutout in the center to redistribute that pressure. Rim brakes"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" deliver satisfactory braking control, and the wide tires provide"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" a smooth, stable ride on paved roads and gravel. Rack and fender"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" mounts facilitate setting up the Roll Low-Entry as your preferred"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" commuter, and the BMX-like handlebar offers space for mounting a"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" flashlight, bell, or phone holder."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"new"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"nHill"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"Summit"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">1200</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"This budget mountain bike from nHill performs well both on bike"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" paths and on the trail. The fork with 100mm of travel absorbs"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" rough terrain. Fat Kenda Booster tires give you grip in corners"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" and on wet trails. The Shimano Tourney drivetrain offered enough"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" gears for finding a comfortable pace to ride uphill, and the"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" Tektro hydraulic disc brakes break smoothly. Whether you want an"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" affordable bike that you can take to work, but also take trail in"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" mountains on the weekends or youβre just after a stable,"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" comfortable ride for the bike path, the Summit gives a good value"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" for money."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"new"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">model</span> <span class="p">=</span> <span class="s">"ThrillCycle"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">brand</span> <span class="p">=</span> <span class="s">"BikeShind"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">price</span> <span class="p">=</span> <span class="m">815</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">description</span> <span class="p">=</span> <span class="s">"An artsy, retro-inspired bicycle thatβs as functional as it is"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" pretty: The ThrillCycle steel frame offers a smooth ride. A"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" 9-speed drivetrain has enough gears for coasting in the city, but"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" we wouldnβt suggest taking it to the mountains. Fenders protect"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" you from mud, and a rear basket lets you transport groceries,"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" flowers and books. The ThrillCycle comes with a limited lifetime"</span> <span class="p">+</span>
</span></span><span class="line"><span class="cl"> <span class="s">" warranty, so this little guy will last you long past graduation."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">condition</span> <span class="p">=</span> <span class="s">"refurbished"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span 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">for</span> <span class="p">(</span><span class="kt">var</span> <span class="n">i</span> <span class="p">=</span> <span class="m">0</span><span class="p">;</span> <span class="n">i</span> <span class="p"><</span> <span class="n">bicycles</span><span class="p">.</span><span class="n">Length</span><span class="p">;</span> <span class="n">i</span><span class="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">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">$"bicycle:{i}"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">bicycles</span><span class="p">[</span><span class="n">i</span><span class="p">]);</span>
</span></span><span class="line"><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="n">SearchResult</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:bicycle"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"@description: kids"</span><span class="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">res1</span><span class="p">);</span> <span class="c1">// >>> 2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'ft1' 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">SearchResult</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:bicycle"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"@model: ka*"</span><span class="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">res2</span><span class="p">.</span><span class="n">TotalResults</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="c1">// Tests for 'ft2' 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">SearchResult</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:bicycle"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"@brand: *bikes"</span><span class="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">res3</span><span class="p">.</span><span class="n">TotalResults</span><span class="p">);</span> <span class="c1">// >>> 2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'ft3' 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">SearchResult</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:bicycle"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"%optamized%"</span><span class="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">res4</span><span class="p">.</span><span class="n">TotalResults</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="c1">// Tests for 'ft4' 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">SearchResult</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"idx:bicycle"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"%%optamised%%"</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="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="n">TotalResults</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="c1">// Tests for 'ft5' 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_query_ft-stepft5')" 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_query_ft-stepft5" 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/QueryFtExample.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>
<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/query/full-text/"/>
<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/uninstalling/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Uninstall Redis Enterprise Software
</h1>
<p>
Use the script
<code>
rl_uninstall.sh
</code>
to uninstall Redis Enterprise Software and remove its files from a node. The script also deletes all Redis data and configuration from the node.
</p>
<p>
The uninstall script does not remove the node from the cluster, but the node's status changes to down. For node removal instructions, see
<a href="/docs/latest/operate/rs/7.4/clusters/remove-node/">
Remove a cluster node
</a>
.
</p>
<h2 id="uninstall-redis-enterprise-software">
Uninstall Redis Enterprise Software
</h2>
<p>
To uninstall Redis Enterprise Software from a cluster node:
</p>
<ol>
<li>
<p>
Navigate to the script's location, which is in
<code>
/opt/redislabs/bin/
</code>
by default.
</p>
</li>
<li>
<p>
Run the uninstall script as the root user:
</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>
</ol>
<p>
When you run the uninstall script on a node, it only uninstalls Redis Enterprise Software from that node. To uninstall Redis Enterprise Software for the entire cluster, run the uninstall script on each cluster node.
</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/installing-upgrading/uninstalling/"/>
<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/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/7.4/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/operate/rs/security/access-control/ldap/.html | <section class="prose w-full py-12 max-w-none">
<h1>
LDAP authentication
</h1>
<p class="text-lg -mt-5 mb-10">
Describes how Redis Enterprise Software integrates LDAP authentication and authorization. Also describes how to enable LDAP for your deployment of Redis Enterprise Software.
</p>
<p>
Redis Enterprise Software supports
<a href="https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol">
Lightweight Directory Access Protocol
</a>
(LDAP) authentication and authorization through its
<a href="/docs/latest/operate/rs/security/access-control/">
role-based access controls
</a>
(RBAC). You can use LDAP to authorize access to the Cluster Manager UI and to control database access.
</p>
<p>
You can configure LDAP roles using the Redis Enterprise Cluster Manager UI or
<a href="/docs/latest/operate/rs/references/rest-api/requests/ldap_mappings/">
REST API
</a>
.
</p>
<h2 id="how-it-works">
How it works
</h2>
<p>
Here's how role-based LDAP integration works:
</p>
<a href="/docs/latest/images/rs/access-control-ldap-diagram.png" sdata-lightbox="/images/rs/access-control-ldap-diagram.png">
<img alt="LDAP overview" src="/docs/latest/images/rs/access-control-ldap-diagram.png"/>
</a>
<ol>
<li>
<p>
A user signs in with their LDAP credentials.
</p>
<p>
Based on the LDAP configuration details, the username is mapped to an LDAP Distinguished Name.
</p>
</li>
<li>
<p>
A simple
<a href="https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol#Bind_(authenticate)">
LDAP bind request
</a>
is attempted using the Distinguished Name and the password. The sign-in fails if the bind fails.
</p>
</li>
<li>
<p>
Obtain the userβs LDAP group memberships.
</p>
<p>
Using configured LDAP details, obtain a list of the userβs group memberships.
</p>
</li>
<li>
<p>
Compare the userβs LDAP group memberships to those mapped to local roles.
</p>
</li>
<li>
<p>
Determine if one of the user's groups is authorized to access the target resource. If so, the user is granted the level of access authorized to the role.
</p>
</li>
</ol>
<p>
To access the Cluster Manager UI, the user needs to belong to an LDAP group mapped to an administrative role.
</p>
<p>
For database access, the user needs to belong to an LDAP group mapped to a role listed in the databaseβs access control list (ACL). The rights granted to the group determine the user's level of access.
</p>
<h2 id="prerequisites">
Prerequisites
</h2>
<p>
Before you enable LDAP in Redis Enterprise, you need:
</p>
<ol>
<li>
<p>
The following LDAP details:
</p>
<ul>
<li>
Server URI, including host, port, and protocol details.
</li>
<li>
Certificate details for secure protocols.
</li>
<li>
Bind credentials, including Distinguished Name, password, and (optionally) client public and private keys for certificate authentication.
</li>
<li>
Authentication query details, whether template or query.
</li>
<li>
Authorization query details, whether attribute or query.
</li>
<li>
The Distinguished Names of LDAP groups youβll use to authorize access to Redis Enterprise resources.
</li>
</ul>
</li>
<li>
<p>
The LDAP groups that correspond to the levels of access you wish to authorize. Each LDAP group will be mapped to a Redis Enterprise access control role.
</p>
</li>
<li>
<p>
A Redis Enterprise access control role for each LDAP group. Before you enable LDAP, you need to set up
<a href="/docs/latest/operate/rs/security/access-control/">
role-based access controls
</a>
(RBAC).
</p>
</li>
</ol>
<h2 id="enable-ldap">
Enable LDAP
</h2>
<p>
To enable LDAP:
</p>
<ol>
<li>
<p>
From
<strong>
Access Control > LDAP
</strong>
in the Cluster Manager UI, select the
<strong>
Configuration
</strong>
tab and
<a href="/docs/latest/operate/rs/security/access-control/ldap/enable-role-based-ldap/">
enable LDAP access
</a>
.
</p>
<a href="/docs/latest/images/rs/access-control-ldap-panel.png" sdata-lightbox="/images/rs/access-control-ldap-panel.png">
<img alt="Enable LDAP Panel" src="/docs/latest/images/rs/access-control-ldap-panel.png"/>
</a>
</li>
<li>
<p>
Map LDAP groups to
<a href="/docs/latest/operate/rs/security/access-control/ldap/map-ldap-groups-to-roles/">
access control roles
</a>
.
</p>
</li>
<li>
<p>
Update database access control lists (ACLs) to
<a href="/docs/latest/operate/rs/security/access-control/ldap/update-database-acls/">
authorize role access
</a>
.
</p>
</li>
</ol>
<p>
If you already have appropriate roles, you can update them to include LDAP groups.
</p>
<h2 id="more-info">
More info
</h2>
<ul>
<li>
Enable and configure
<a href="/docs/latest/operate/rs/security/access-control/ldap/enable-role-based-ldap/">
role-based LDAP
</a>
</li>
<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 Enterprise 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/"/>
<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/basic-constructs/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Basic constructs
</h1>
<p class="text-lg -mt-5 mb-10">
Basic constructs for searching and querying Redis data
</p>
<p>
You can use Redis Stack as a powerful search and query engine. It allows you to create indexes and perform efficient queries on structured data, as well as text-based and vector searches on unstructured data.
</p>
<p>
This section introduces the basic constructs of querying and searching, and explains how to use them to build powerful search capabilities into your applications.
</p>
<h2 id="documents">
Documents
</h2>
<p>
A document is the basic unit of information. It can be any hash or JSON data object you want to be able to index and search. Each document is uniquely identifiable by its key name.
</p>
<h2 id="fields">
Fields
</h2>
<p>
A document consists of multiple fields, where each field represents a specific attribute or property of the document. Fields can store different types of data, such as strings, numbers, geo-location or even more complex structures like vectors. By indexing these fields, you enable efficient querying and searching based on their values.
</p>
<p>
Not all documents need to have the same fields. You can include or exclude fields based on the specific requirements of your application or data model.
</p>
<h2 id="indexing-fields">
Indexing fields
</h2>
<p>
Not all fields are relevant to perform search operations, and indexing all fields may lead to unnecessary overhead. That's why you have the flexibility to choose which fields should be indexed for efficient search operations. By indexing a field, you enable Redis Stack to create an index structure that optimizes search performance on that field.
</p>
<p>
Fields that are not indexed will not contribute to search results. However, they can still be retrieved as part of the document data when fetching search results.
</p>
<h2 id="schema">
Schema
</h2>
<p>
The index structure is defined by a schema. The schema defines how fields are stored and indexed. It specifies the type of each field and other important information.
</p>
<p>
To create an index, you need to define the schema for your collection. Learn more about how to define the schema on the
<a href="/docs/latest/develop/interact/search-and-query/basic-constructs/schema-definition/">
schema definition
</a>
page.
</p>
<h2 id="learn-more">
Learn more:
</h2>
<nav>
<a href="/docs/latest/develop/interact/search-and-query/basic-constructs/schema-definition/">
Schema definition
</a>
<p>
How to define the schema of an index.
</p>
<a href="/docs/latest/develop/interact/search-and-query/basic-constructs/field-and-type-options/">
Field and type options
</a>
<p>
Available field types and options.
</p>
<a href="/docs/latest/develop/interact/search-and-query/basic-constructs/configuration-parameters/">
Configuration parameters
</a>
<p>
Querying and searching in Redis Stack can be tuned through multiple configuration parameters. Some of these parameters can only be set at load-time, while other parameters can be set either at load-time or at run-time.
</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/develop/interact/search-and-query/basic-constructs/"/>
<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/memory-performance/eviction-policy/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Eviction policy
</h1>
<p class="text-lg -mt-5 mb-10">
The eviction policy determines what happens when a database reaches its memory limit.
</p>
<p>
The eviction policy determines what happens when a database reaches its memory limit.
</p>
<p>
To make room for new data, older data is
<em>
evicted
</em>
(removed) according to the selected policy.
</p>
<p>
To prevent this from happening, make sure your database is large enough to hold all desired keys.
</p>
<table>
<thead>
<tr>
<th>
<strong>
EvictionΒ Policy
</strong>
</th>
<th>
<strong>
Description
</strong>
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
noeviction
</td>
<td>
New values aren't saved when memory limit is reached
<br/>
<br/>
When a database uses replication, this applies to the primary database
</td>
</tr>
<tr>
<td>
allkeys-lru
</td>
<td>
Keeps most recently used keys; removes least recently used (LRU) keys
</td>
</tr>
<tr>
<td>
allkeys-lfu
</td>
<td>
Keeps frequently used keys; removes least frequently used (LFU) keys
</td>
</tr>
<tr>
<td>
allkeys-random
</td>
<td>
Randomly removes keys
</td>
</tr>
<tr>
<td>
volatile-lru
</td>
<td>
Removes least recently used keys with
<code>
expire
</code>
field set to true
</td>
</tr>
<tr>
<td>
volatile-lfu
</td>
<td>
Removes least frequently used keys with
<code>
expire
</code>
field set to true
</td>
</tr>
<tr>
<td>
volatile-random
</td>
<td>
Randomly removes keys with
<code>
expire
</code>
field set to true
</td>
</tr>
<tr>
<td>
volatile-ttl
</td>
<td>
Removes least frequently used keys with
<code>
expire
</code>
field set to true and the shortest remaining time-to-live (TTL) value
</td>
</tr>
</tbody>
</table>
<h2 id="eviction-policy-defaults">
Eviction policy defaults
</h2>
<p>
<code>
volatile-lru
</code>
is the default eviction policy for most databases.
</p>
<p>
The default policy for
<a href="/docs/latest/operate/rs/7.4/databases/active-active/">
Active-Active databases
</a>
is
<em>
noeviction
</em>
policy.
</p>
<h2 id="active-active-database-eviction">
Active-Active database eviction
</h2>
<p>
The eviction policy mechanism for Active-Active databases kicks in earlier than for standalone databases because it requires propagation to all participating clusters.
The eviction policy starts to evict keys when one of the Active-Active instances reaches 80% of its memory limit. If memory usage continues to rise while the keys are being evicted, the rate of eviction will increase to prevent reaching the Out-of-Memory state.
As with standalone Redis Enterprise databases, Active-Active eviction is calculated per shard.
To prevent over eviction, internal heuristics might prevent keys from being evicted when the shard reaches the 80% memory limit. In such cases, keys will get evicted only when shard memory reaches 100%.
</p>
<p>
In case of network issues between Active-Active instances, memory can be freed only when all instances are in sync. If there is no communication between participating clusters, it can result in eviction of all keys and the instance reaching an Out-of-Memory state.
</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>
Data eviction policies are not supported for Active-Active databases with Auto Tiering .
</div>
</div>
<h2 id="avoid-data-eviction">
Avoid data eviction
</h2>
<p>
To avoid data eviction, make sure your database is large enough to hold required values.
</p>
<p>
For larger databases, consider using
<a href="/docs/latest/operate/rs/7.4/databases/auto-tiering/">
Auto Tiering
</a>
.
</p>
<p>
Auto Tiering stores actively-used data (also known as
<em>
hot data
</em>
) in RAM and the remaining data in flash memory (SSD).
This lets you retain more data while ensuring the fastest access to the most critical data.
</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/memory-performance/eviction-policy/"/>
<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/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Database actions requests
</h1>
<p class="text-lg -mt-5 mb-10">
Database action requests
</p>
<h2 id="backup">
Backup
</h2>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="/docs/latest/operate/rs/references/rest-api/requests/bdbs/actions/backup_reset_status/#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="export">
Export
</h2>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="/docs/latest/operate/rs/references/rest-api/requests/bdbs/actions/export_reset_status/#put-bdbs-actions-export-reset-status">
PUT
</a>
</td>
<td>
<code>
/v1/bdbs/{uid}/actions/export_reset_status
</code>
</td>
<td>
Reset database export status
</td>
</tr>
<tr>
<td>
<a href="/docs/latest/operate/rs/references/rest-api/requests/bdbs/actions/export/#post-bdbs-actions-export">
POST
</a>
</td>
<td>
<code>
/v1/bdbs/{uid}/actions/export
</code>
</td>
<td>
Initiate database export
</td>
</tr>
</tbody>
</table>
<h2 id="import">
Import
</h2>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="/docs/latest/operate/rs/references/rest-api/requests/bdbs/actions/import_reset_status/#put-bdbs-actions-import-reset-status">
PUT
</a>
</td>
<td>
<code>
/v1/bdbs/{uid}/actions/import_reset_status
</code>
</td>
<td>
Reset database import status
</td>
</tr>
<tr>
<td>
<a href="/docs/latest/operate/rs/references/rest-api/requests/bdbs/actions/import/#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="optimize-shards-placement">
Optimize shards placement
</h2>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="/docs/latest/operate/rs/references/rest-api/requests/bdbs/actions/optimize_shards_placement/#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="rebalance">
Rebalance
</h2>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="/docs/latest/operate/rs/references/rest-api/requests/bdbs/actions/rebalance/#put-bdbs-actions-rebalance">
PUT
</a>
</td>
<td>
<code>
/v1/bdbs/{uid}/actions/rebalance
</code>
</td>
<td>
Rebalance database shards
</td>
</tr>
</tbody>
</table>
<h2 id="recover">
Recover
</h2>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="/docs/latest/operate/rs/references/rest-api/requests/bdbs/actions/recover/#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="/docs/latest/operate/rs/references/rest-api/requests/bdbs/actions/recover/#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="resume-traffic">
Resume traffic
</h2>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="/docs/latest/operate/rs/references/rest-api/requests/bdbs/actions/resume_traffic/#post-bdbs-actions-resume-traffic">
POST
</a>
</td>
<td>
<code>
/v1/bdbs/{uid}/actions/resume_traffic
</code>
</td>
<td>
Resume database traffic
</td>
</tr>
</tbody>
</table>
<h2 id="stop-traffic">
Stop traffic
</h2>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="/docs/latest/operate/rs/references/rest-api/requests/bdbs/actions/stop_traffic/#post-bdbs-actions-stop-traffic">
POST
</a>
</td>
<td>
<code>
/v1/bdbs/{uid}/actions/stop_traffic
</code>
</td>
<td>
Stop database traffic
</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/"/>
<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/shard/sync/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Sync object
</h1>
<p class="text-lg -mt-5 mb-10">
Documents the sync 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>
progress
</td>
<td>
integer
</td>
<td>
Number of bytes remaining in current sync
</td>
</tr>
<tr>
<td>
status
</td>
<td>
'in_progress'
<br/>
'idle'
<br/>
'link_down'
</td>
<td>
Indication of the shard's current sync status
</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/shard/sync/"/>
<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/manage-passwords/rotate-passwords/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Rotate passwords
</h1>
<p class="text-lg -mt-5 mb-10">
Rotate user passwords.
</p>
<p>
Redis Enterprise Software lets you implement password rotation policies using the
<a href="/docs/latest/operate/rs/references/rest-api/">
REST API
</a>
.
</p>
<p>
You can add a new password for a database user without immediately invalidating the old one (which might cause authentication errors in production).
</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>
Password rotation does not work for the default user.
<a href="/docs/latest/operate/rs/security/access-control/create-users/">
Add additional users
</a>
to enable password rotation.
</div>
</div>
<h2 id="password-rotation-policies">
Password rotation policies
</h2>
<p>
For user access to the Redis Enterprise Software Cluster Manager UI,
you can set a
<a href="/docs/latest/operate/rs/security/access-control/manage-passwords/password-expiration/">
password expiration policy
</a>
to prompt the user to change their password.
</p>
<p>
However, for database connections that rely on password authentication,
you need to allow for authentication with the existing password while you roll out the new password to your systems.
</p>
<p>
With the Redis Enterprise Software REST API, you can add additional passwords to a user account for authentication to the database or the Cluster Manager UI and API.
</p>
<p>
After the old password is replaced in the database connections, you can delete the old password to finish the password rotation process.
</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>
Multiple passwords are only supported using the REST API.
If you reset the password for a user in the Cluster Manager UI,
the new password replaces all other passwords for that user.
</div>
</div>
<p>
The new password cannot already exist as a password for the user and must meet the
<a href="/docs/latest/operate/rs/security/access-control/manage-passwords/password-complexity-rules/">
password complexity
</a>
requirements, if enabled.
</p>
<h2 id="rotate-password">
Rotate password
</h2>
<p>
To rotate the password of a user account:
</p>
<ol>
<li>
<p>
Add an additional password to a user account with
<a href="/docs/latest/operate/rs/references/rest-api/requests/users/password/#add-password">
<code>
POST /v1/users/password
</code>
</a>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">POST https://<span class="o">[</span>host<span class="o">][</span>:port<span class="o">]</span>/v1/users/password
</span></span><span class="line"><span class="cl"> <span class="s1">'{"username":"<username>", "old_password":"<an_existing_password>", "new_password":"<a_new_password>"}'</span>
</span></span></code></pre>
</div>
<p>
After you send this request, you can authenticate with both the old and the new password.
</p>
</li>
<li>
<p>
Update the password in all database connections that connect with the user account.
</p>
</li>
<li>
<p>
Delete the original password with
<a href="/docs/latest/operate/rs/references/rest-api/requests/users/password/#update-password">
<code>
DELETE /v1/users/password
</code>
</a>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">DELETE https://<span class="o">[</span>host<span class="o">][</span>:port<span class="o">]</span>/v1/users/password
</span></span><span class="line"><span class="cl"> <span class="s1">'{"username":"<username>", "old_password":"<an_existing_password>"}'</span>
</span></span></code></pre>
</div>
<p>
If there is only one valid password for a user account, you cannot delete that password.
</p>
</li>
</ol>
<h2 id="replace-all-passwords">
Replace all passwords
</h2>
<p>
You can also replace all existing passwords for a user account with a single password that does not match any existing passwords.
This can be helpful if you suspect that your passwords are compromised and you want to quickly resecure the account.
</p>
<p>
To replace all existing passwords for a user account with a single new password, use
<a href="/docs/latest/operate/rs/references/rest-api/requests/users/password/#delete-password">
<code>
PUT /v1/users/password
</code>
</a>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">PUT https://<span class="o">[</span>host<span class="o">][</span>:port<span class="o">]</span>/v1/users/password
</span></span><span class="line"><span class="cl"> <span class="s1">'{"username":"<username>", "old_password":"<an_existing_password>", "new_password":"<a_new_password>"}'</span>
</span></span></code></pre>
</div>
<p>
All of the existing passwords are deleted and only the new password is valid.
</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 send the above request without specifying it is a
<code>
PUT
</code>
request, the new password is added to the list of existing passwords.
</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/security/access-control/manage-passwords/rotate-passwords/"/>
<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/connection/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Connection management commands compatibility
</h1>
<p class="text-lg -mt-5 mb-10">
Connection management commands compatibility.
</p>
<p>
The following tables show which Redis Community Edition
<a href="/docs/latest/commands/?group=connection">
connection management 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/auth/">
AUTH
</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/client-caching/">
CLIENT CACHING
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not 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/client-getname/">
CLIENT GETNAME
</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/client-getredir/">
CLIENT GETREDIR
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not 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/client-id/">
CLIENT ID
</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">
Because Redis Enterprise clustering allows
<a href="/docs/latest/operate/rs/databases/configure/proxy-policy/">
multiple active proxies
</a>
,
<code>
CLIENT ID
</code>
cannot guarantee incremental IDs between clients that connect to different nodes under multi proxy policies.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/client-info/">
CLIENT INFO
</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/client-kill/">
CLIENT KILL
</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/client-list/">
CLIENT LIST
</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/client-no-evict/">
CLIENT NO-EVICT
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not 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/client-no-touch/">
CLIENT
<nobr>
NO-TOUCH
</nobr>
</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/client-pause/">
CLIENT PAUSE
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not 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/client-reply/">
CLIENT REPLY
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not 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/client-setinfo/">
CLIENT SETINFO
</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/client-setname/">
CLIENT SETNAME
</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/client-tracking/">
CLIENT TRACKING
</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/client-trackinginfo/">
CLIENT TRACKINGINFO
</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/client-unblock/">
CLIENT UNBLOCK
</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/client-unpause/">
CLIENT UNPAUSE
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not 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/echo/">
ECHO
</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/hello/">
HELLO
</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/ping/">
PING
</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/quit/">
QUIT
</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">
Deprecated as of Redis v7.2.0.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/reset/">
RESET
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not 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/select/">
SELECT
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Redis Enterprise does not support shared databases due to potential negative performance impacts and blocks any related commands. The
<code>
SELECT
</code>
command is supported solely for compatibility with Redis Community Edition but does not perform any operations in Redis Enterprise.
</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/connection/"/>
<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/v1.1.0/.html | <section class="prose w-full py-12">
<h1>
RedisInsight v1.1, December 2019
</h1>
<p class="text-lg -mt-5 mb-10">
Stability improvements and other fixes
</p>
<h2 id="redisinsight-v110-release-notes-december-2019">
RedisInsight v1.1.0 release notes (December 2019)
</h2>
<h3 id="headlines">
Headlines
</h3>
<ul>
<li>
This release improves overall stability and provides fixes for issues found after the previous release.
</li>
</ul>
<h3 id="details">
Details
</h3>
<ul>
<li>
Minor Enhancements:
<ul>
<li>
Core:
<ul>
<li>
Enable mouse wheel support inside the
<code>
querycard
</code>
.
</li>
</ul>
</li>
<li>
Browser:
<ul>
<li>
Enable enter key press for adding keys in browser
</li>
</ul>
</li>
<li>
RediSearch:
<ul>
<li>
Disable HIGHLIGHT markup in JSON view.
</li>
</ul>
</li>
<li>
Browser:
<ul>
<li>
Improve error message when database is unreachable
</li>
<li>
Add a reload/refresh button to refresh the value of a key
</li>
<li>
Enable enter key press for adding keys in browser
</li>
<li>
Improve error message for unsupported value types
</li>
</ul>
</li>
</ul>
</li>
<li>
Bug Fixes:
<ul>
<li>
RedisGraph:
<ul>
<li>
Fix initial node placement in the view.
</li>
<li>
Fix initial zoom with respect to the number of nodes in the result.
</li>
</ul>
</li>
<li>
Other minor fixes.
</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/develop/tools/insight/release-notes/v1.1.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/rs/installing-upgrading/install/manage-installation-questions/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Manage installation questions
</h1>
<p class="text-lg -mt-5 mb-10">
Describes Redis Enterprise Software installation questions and how to answer them automatically.
</p>
<p>
Several questions are displayed during the Redis Enterprise Software installation process.
</p>
<p>
Here, you'll find a list of these questions and learn how to automatically answer these questions to perform a silent install.
</p>
<h2 id="installation-questions">
Installation questions
</h2>
<p>
Several questions appear during installation:
</p>
<ul>
<li>
<p>
<strong>
Linux swap file
</strong>
-
<code>
Swap is enabled. Do you want to proceed? [Y/N]?
</code>
</p>
<p>
We recommend that you
<a href="/docs/latest/operate/rs/installing-upgrading/configuring/linux-swap/">
disable Linux swap
</a>
in the operating system configuration
to give Redis Enterprise Software control of the memory allocation.
</p>
</li>
<li>
<p>
<strong>
Automatic OS tuning
</strong>
-
<code>
Do you want to automatically tune the system for best performance [Y/N]?
</code>
</p>
<p>
To allow the installation process to optimize the OS for Redis Enterprise Software, answer
<code>
Y
</code>
.
The installation process prompts you for additional information.
</p>
<p>
The
<code>
/opt/redislabs/sbin/systune.sh
</code>
file contains details about the tuning process.
</p>
</li>
<li>
<p>
<strong>
Network time
</strong>
-
<code>
Do you want to set up NTP time synchronization now [Y/N]?
</code>
</p>
<p>
Redis Enterprise Software requires that all cluster nodes have synchronized time.
You can either let the installation process configure NTP
or you can
<a href="/docs/latest/operate/rs/clusters/configure/sync-clocks/">
configure NTP manually
</a>
.
</p>
</li>
<li>
<p>
<strong>
Firewall ports
</strong>
-
<code>
Would you like to open RedisLabs cluster ports on the default firewall zone [Y/N]?
</code>
</p>
<p>
Redis Enterprise Software requires that all nodes have
<a href="/docs/latest/operate/rs/networking/port-configurations/">
specific network ports
</a>
open.
To open the ports, you can:
</p>
<ul>
<li>
Answer
<code>
Y
</code>
to let the installation process open these ports.
</li>
<li>
Answer
<code>
N
</code>
and configure the firewall manually for
<a href="/docs/latest/operate/rs/installing-upgrading/configuring/centos-rhel-firewall/">
RHEL/CentOS firewall
</a>
.
</li>
<li>
Answer
<code>
N
</code>
and configure the firewall on the node manually for your OS.
</li>
</ul>
</li>
<li>
<p>
<strong>
Installation verification (rlcheck)
</strong>
-
<code>
Would you like to run rlcheck to verify proper configuration? [Y/N]?
</code>
</p>
<p>
Run the
<code>
rlcheck
</code>
installation verification to make sure that the installation completed successfully.
If you want to run this verification at a later time, you can run:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">/opt/redislabs/bin/rlcheck
</span></span></code></pre>
</div>
</li>
<li>
<p>
<strong>
User already exists
</strong>
-
<code>
The user 'redislabs' already exists, which may lead to problems if it wasn't configured correctly. Would you like to proceed with the installation? (Y/N)?
</code>
</p>
</li>
<li>
<p>
<strong>
Group already exists
</strong>
-
<code>
The group 'redislabs' already exists, which may lead to problems if it wasn't configured correctly. Would you like to proceed with the installation? (Y/N)?
</code>
</p>
</li>
</ul>
<h2 id="answer-install-questions-automatically">
Answer install questions automatically
</h2>
<p>
To perform a silent (or automated) install, answer the questions when you start the
<a href="/docs/latest/operate/rs/installing-upgrading/install/install-on-linux/">
install
</a>
.
</p>
<h3 id="answer-yes-to-all-questions">
Answer yes to all questions
</h3>
<p>
To automatically answer
<code>
yes
</code>
to all questions (which accepts the default values), run the
<a href="/docs/latest/operate/rs/installing-upgrading/install/install-script/">
installation script
</a>
with the
<code>
-y
</code>
parameter:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">./install.sh -y
</span></span></code></pre>
</div>
<h3 id="configure-file-to-answer">
Configure file to answer
</h3>
<p>
Use an answer file to manage your response:
</p>
<ol>
<li>
<p>
Create a text file to serve as an answer file.
</p>
<p>
The answer file can contain any of the parameters for the installation questions and indicate the answer for each question with
<code>
yes
</code>
or
<code>
no
</code>
.
</p>
<p>
For example:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl"><span class="nv">ignore_swap</span><span class="o">=</span>no
</span></span><span class="line"><span class="cl"><span class="nv">systune</span><span class="o">=</span>yes
</span></span><span class="line"><span class="cl"><span class="nv">ntp</span><span class="o">=</span>no
</span></span><span class="line"><span class="cl"><span class="nv">firewall</span><span class="o">=</span>no
</span></span><span class="line"><span class="cl"><span class="nv">rlcheck</span><span class="o">=</span>yes
</span></span><span class="line"><span class="cl"><span class="nv">ignore_existing_osuser_osgroup</span><span class="o">=</span>no
</span></span></code></pre>
</div>
<p>
If you use
<code>
systune=yes
</code>
, the installation answers
<code>
yes
</code>
to all of the system tuning questions.
</p>
</li>
<li>
<p>
Run the
<a href="/docs/latest/operate/rs/installing-upgrading/install/install-script/">
installation script
</a>
with the
<code>
-c
</code>
command-line option and add the path to the answer file.
</p>
<p>
For example:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">./install.sh -c /home/user/answers
</span></span></code></pre>
</div>
</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/install/manage-installation-questions/"/>
<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/bootstrap/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Bootstrap requests
</h1>
<p class="text-lg -mt-5 mb-10">
Bootstrap requests
</p>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="#get-bootstrap">
GET
</a>
</td>
<td>
<code>
/v1/boostrap
</code>
</td>
<td>
Get the local node's bootstrap status
</td>
</tr>
<tr>
<td>
<a href="#post-bootstrap">
POST
</a>
</td>
<td>
<code>
/v1/bootstrap/{action}
</code>
</td>
<td>
Initiate bootstrapping
</td>
</tr>
</tbody>
</table>
<h2 id="get-bootstrap">
Get bootstrap status
</h2>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">GET /v1/bootstrap
</span></span></code></pre>
</div>
<p>
Get the local node's bootstrap status.
</p>
<p>
This request is accepted as soon the cluster software is installed and before the node is part of an active cluster.
</p>
<p>
Once the node is part of an active cluster, authentication is required.
</p>
<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 /bootstrap
</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>
Accept
</td>
<td>
application/json
</td>
<td>
Accepted media type
</td>
</tr>
</tbody>
</table>
<h3 id="get-response">
Response
</h3>
<p>
The JSON response object contains a
<code>
bootstrap_status
</code>
object and a
<code>
local_node_info
</code>
object.
</p>
<p>
The
<code>
bootstrap_status
</code>
object contains the following information:
</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>
recovering_cluster
</code>
: In the process of recovering a 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>
<p>
The
<code>
local_node_info
</code>
object is a subset of a
<a href="/docs/latest/operate/rs/references/rest-api/objects/node/">
node object
</a>
that provides information about the node configuration.
</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="nt">"bootstrap_status"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"start_time"</span><span class="p">:</span> <span class="s2">"2014-08-29T11:19:49Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"end_time"</span><span class="p">:</span> <span class="s2">"2014-08-29T11:19:49Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"state"</span><span class="p">:</span> <span class="s2">"completed"</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"local_node_info"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"uid"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"software_version"</span><span class="p">:</span> <span class="s2">"0.90.0-1"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"cores"</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"ephemeral_storage_path"</span><span class="p">:</span> <span class="s2">"/var/opt/redislabs/tmp"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"ephemeral_storage_size"</span><span class="p">:</span> <span class="mf">1018889.8304</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"os_version"</span><span class="p">:</span> <span class="s2">"Ubuntu 14.04 LTS"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"persistent_storage_path"</span><span class="p">:</span> <span class="s2">"/var/opt/redislabs/persist/redis"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"persistent_storage_size"</span><span class="p">:</span> <span class="mf">1018889.8304</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"total_memory"</span><span class="p">:</span> <span class="mi">24137</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"uptime"</span><span class="p">:</span> <span class="mi">50278</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"available_addrs"</span><span class="p">:</span> <span class="p">[{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"address"</span><span class="p">:</span> <span class="s2">"172.16.50.122"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"format"</span><span class="p">:</span> <span class="s2">"ipv4"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"if_name"</span><span class="p">:</span> <span class="s2">"eth0"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"private"</span><span class="p">:</span> <span class="kc">true</span>
</span></span><span class="line"><span class="cl"> <span class="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">"address"</span><span class="p">:</span> <span class="s2">"10.0.3.1"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"format"</span><span class="p">:</span> <span class="s2">"ipv4"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"if_name"</span><span class="p">:</span> <span class="s2">"lxcbr0"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"private"</span><span class="p">:</span> <span class="kc">true</span>
</span></span><span class="line"><span class="cl"> <span class="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">"address"</span><span class="p">:</span> <span class="s2">"172.17.0.1"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"format"</span><span class="p">:</span> <span class="s2">"ipv4"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"if_name"</span><span class="p">:</span> <span class="s2">"docker0"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"private"</span><span class="p">:</span> <span class="kc">true</span>
</span></span><span class="line"><span class="cl"> <span class="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">"address"</span><span class="p">:</span> <span class="s2">"2001:db8:0:f101::1"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"format"</span><span class="p">:</span> <span class="s2">"ipv6"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"if_name"</span><span class="p">:</span> <span class="s2">"eth0"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"private"</span><span class="p">:</span> <span class="kc">false</span>
</span></span><span class="line"><span class="cl"> <span class="p">}]</span>
</span></span><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>
<h3 id="get-error-codes">
Error codes
</h3>
<table>
<thead>
<tr>
<th>
Code
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
config_error
</td>
<td>
An error related to the bootstrap configuration provided (e.g. bad JSON).
</td>
</tr>
<tr>
<td>
connect_error
</td>
<td>
Failed to connect to cluster (e.g. FQDN DNS could not resolve, no/wrong node IP provided, etc.
</td>
</tr>
<tr>
<td>
access_denied
</td>
<td>
Invalid credentials supplied.
</td>
</tr>
<tr>
<td>
invalid_license
</td>
<td>
The license string provided is invalid. Additional info can be fetched from the
<code>
error_details
</code>
object, which includes the violation code in case the license is valid but its terms are violated.
</td>
</tr>
<tr>
<td>
repair_required
</td>
<td>
Cluster is in degraded mode and can only accept replacement nodes. When this happens,
<code>
error_details
</code>
contains two fields:
<code>
failed_nodes
</code>
and
<code>
replace_candidate
</code>
. The
<code>
failed_nodes
</code>
field is an array of objects, each describing a failed node with at least a
<code>
uid
</code>
field and an optional
<code>
rack_id
</code>
.
<code>
replace_candidate
</code>
is the UID of the node most suitable for replacement.
</td>
</tr>
<tr>
<td>
insufficient_node_memory
</td>
<td>
An attempt to replace a dead node fails because the replaced node does not have enough memory. When this happens, error_details contains a required_memory field which indicates the node memory requirement.
</td>
</tr>
<tr>
<td>
insufficient_node_flash
</td>
<td>
An attempt to replace a dead node fails because the replaced node does not have enough flash. When this happens,
<code>
error_details
</code>
contains a
<code>
required_flash
</code>
field which indicates the node flash requirement.
</td>
</tr>
<tr>
<td>
time_not_sync
</td>
<td>
An attempt to join a node with system time not synchronized with the rest of the cluster.
</td>
</tr>
<tr>
<td>
rack_id_required
</td>
<td>
An attempt to join a node with no
<code>
rack_id
</code>
in a rack-aware cluster. In addition, a
<code>
current_rack_ids
</code>
field will include an array of currently used rack ids.
</td>
</tr>
<tr>
<td>
socket_directory_mismatch
</td>
<td>
An attempt to join a node with a socket directory setting that differs from the cluster
</td>
</tr>
<tr>
<td>
node_config_mismatch
</td>
<td>
An attempt to join a node with a configuration setting (e.g. confdir, osuser, installdir) that differs from the cluster
</td>
</tr>
<tr>
<td>
path_error
</td>
<td>
A needed path does not exist or is not accessable.
</td>
</tr>
<tr>
<td>
internal_error
</td>
<td>
A different, unspecified internal error was encountered.
</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>
No error
</td>
</tr>
</tbody>
</table>
<h2 id="post-bootstrap">
Start bootstrapping
</h2>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">POST /v1/bootstrap/<span class="o">{</span>action<span class="o">}</span>
</span></span></code></pre>
</div>
<p>
Initiate bootstrapping.
</p>
<p>
The request must contain a bootstrap configuration JSON object, as
described in
<a href="/docs/latest/operate/rs/references/rest-api/objects/">
Object attributes
</a>
or a minimal subset.
</p>
<p>
Bootstrapping is permitted only when the current bootstrap state is
<code>
idle
</code>
or
<code>
error
</code>
(in which case the process will restart with the new
configuration).
</p>
<p>
This request is asynchronous - once the request has been accepted,
the caller is expected to poll bootstrap status while waiting for it to
complete.
</p>
<h3 id="post-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">POST /bootstrap/create_cluster
</span></span></code></pre>
</div>
<h4 id="example-json-body-1">
Example JSON body
</h4>
<h5 id="join-cluster">
Join cluster
</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">"action"</span><span class="p">:</span> <span class="s2">"join_cluster"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"cluster"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"nodes"</span><span class="p">:[</span> <span class="s2">"1.1.1.1"</span><span class="p">,</span> <span class="s2">"2.2.2.2"</span> <span class="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"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"paths"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"persistent_path"</span><span class="p">:</span> <span class="s2">"/path/to/persistent/storage"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"ephemeral_path"</span><span class="p">:</span> <span class="s2">"/path/to/ephemeral/storage"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"bigstore_path"</span><span class="p">:</span> <span class="s2">"/path/to/bigstore/storage"</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"bigstore_driver"</span><span class="p">:</span> <span class="s2">"speedb"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"identity"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"addr"</span><span class="p">:</span><span class="s2">"1.2.3.4"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"external_addr"</span><span class="p">:[</span><span class="s2">"2001:0db8:85a3:0000:0000:8a2e:0370:7334"</span><span class="p">,</span> <span class="s2">"3.4.5.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="nt">"credentials"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"username"</span><span class="p">:</span> <span class="s2">"my_username"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"password"</span><span class="p">:</span> <span class="s2">"my_password"</span>
</span></span><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>
<h5 id="create-cluster">
Create cluster
</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">"action"</span><span class="p">:</span> <span class="s2">"create_cluster"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"cluster"</span><span class="p">:</span> <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="nt">"name"</span><span class="p">:</span> <span class="s2">"my.cluster"</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"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"paths"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"persistent_path"</span><span class="p">:</span> <span class="s2">"/path/to/persistent/storage"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"ephemeral_path"</span><span class="p">:</span> <span class="s2">"/path/to/ephemeral/storage"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"bigstore_path"</span><span class="p">:</span> <span class="s2">"/path/to/bigredis/storage"</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"identity"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"addr"</span><span class="p">:</span><span class="s2">"1.2.3.4"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"external_addr"</span><span class="p">:[</span><span class="s2">"2001:0db8:85a3:0000:0000:8a2e:0370:7334"</span><span class="p">,</span> <span class="s2">"3.4.5.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="nt">"bigstore_driver"</span><span class="p">:</span> <span class="s2">"rocksdb"</span>
</span></span><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">"credentials"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"username"</span><span class="p">:</span> <span class="s2">"my_username"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"password"</span><span class="p">:</span> <span class="s2">"my_password"</span>
</span></span><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-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>
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="request-body">
Request body
</h4>
<p>
Include a
<a href="/docs/latest/operate/rs/references/rest-api/objects/bootstrap/">
bootstrap object
</a>
in the request body.
</p>
<h3 id="post-response">
Response
</h3>
<h4 id="post-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>
Request received and processing begins.
</td>
</tr>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.10">
409 Conflict
</a>
</td>
<td>
Bootstrap already in progress (check 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/bootstrap/"/>
<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/v1.0.0/.html | <section class="prose w-full py-12">
<h1>
RedisInsight v1.0, November 2019
</h1>
<p class="text-lg -mt-5 mb-10">
The initial release after Redis acquired RDBTools
</p>
<h2 id="redisinsight-v100-release-notes-november-2019">
RedisInsight v1.0.0 release notes (November 2019)
</h2>
<p>
This is the initial release after
<a href="https://www.redislabs.com/blog/redisinsight-gui/">
Redis acquired RDBTools
</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/develop/tools/insight/release-notes/v1.0.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/develop/clients/redis-vl/.html | <section class="prose w-full py-12">
<h1>
Redis vector library guide (Python)
</h1>
<p class="text-lg -mt-5 mb-10">
Connect your Python vector application to a Redis vector database
</p>
<p>
See the
<a href="/docs/latest/integrate/redisvl/">
RedisVL Guide
</a>
for more information.
</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/redis-vl/"/>
<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/networking/cluster-dns/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Configure cluster DNS
</h1>
<p class="text-lg -mt-5 mb-10">
Configure DNS to communicate between nodes in your cluster.
</p>
<p>
By default, Redis Enterprise Software deployments use DNS to communicate between nodes. You can also use the
<a href="/docs/latest/operate/rs/7.4/databases/durability-ha/discovery-service/">
Discovery Service
</a>
, which uses IP addresses to connect and complies with the
<a href="/docs/latest/operate/oss_and_stack/management/sentinel/">
Redis Sentinel API
</a>
supported by Redis Community Edition.
</p>
<p>
Each node in a Redis Enterprise cluster includes a small DNS server to manage internal functions, such as high availability, automatic failover, automatic migration, and so on.
Nodes should only run the DNS server included with the software. Running additional DNS servers can lead to unexpected behavior.
</p>
<h2 id="cluster-name-and-connection-management">
Cluster name and connection management
</h2>
<p>
Whether you're administering Redis Enterprise Software or accessing databases, there are two ways to connect:
</p>
<ul>
<li>
<p>
URL-based connections - URL-based connections use DNS to resolve the fully qualified cluster domain name (FQDN). This means that DNS records might need to be updated when topology changes, such as adding (or removing) nodes from the cluster.
</p>
<p>
Because apps and other client connections rely on the URL (rather than the address), they do not need to be modified when topology changes.
</p>
</li>
<li>
<p>
IP-based connections - IP-based connections do not require DNS setup, as they rely on the underlying TCP/IP addresses. As long as topology changes do not change the address of the cluster nodes, no configuration changes are needed, DNS or otherwise.
</p>
<p>
However, changes to IP addresses (or changes to IP address access) impact all connections to the node, including apps and clients. IP address changes can therefore be unpredictable or time-consuming.
</p>
</li>
</ul>
<h2 id="url-based-connections">
URL-based connections
</h2>
<p>
The fully qualified domain name (FQDN) is the unique cluster identifier that enables clients to connect to the different components of Redis Enterprise Software.
The FQDN is a crucial component of the high-availability mechanism because it's used internally to enable and implement automatic and transparent failover of nodes, databases, shards, and endpoints.
</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>
Setting the cluster's FQDN is a one-time operation, one that cannot be changed after being set.
</div>
</div>
<p>
The FQDN must always comply with the IETF's
<a href="https://datatracker.ietf.org/doc/html/rfc952">
RFC 952
</a>
standard
and section 2.1 of the
<a href="https://datatracker.ietf.org/doc/html/rfc1123">
RFC 1123
</a>
standard.
</p>
<h2 id="identify-the-cluster">
Identify the cluster
</h2>
<p>
To identify the cluster, either use DNS to define a fully qualified domain name or use the IP addresses of each node.
</p>
<h3 id="define-domain-using-dns">
Define domain using DNS
</h3>
<p>
Use DNS if you:
</p>
<ul>
<li>
have your own domain
</li>
<li>
want to integrate the cluster into that domain
</li>
<li>
can access and update the DNS records for that domain
</li>
</ul>
<ol>
<li>
<p>
Make sure that the cluster and at least one node (preferably all nodes) in the cluster
are correctly configured in the DNS with the appropriate NS entries.
</p>
<p>
For example:
</p>
<ul>
<li>
Your domain is:
<code>
mydomain.com
</code>
</li>
<li>
You would like to name the Redis Enterprise Software cluster
<code>
mycluster
</code>
</li>
<li>
You have three nodes in the cluster:
<ul>
<li>
node1 (IP address 1.1.1.1)
</li>
<li>
node2 (2.2.2.2)
</li>
<li>
node3 (3.3.3.3)
</li>
</ul>
</li>
</ul>
</li>
<li>
<p>
In the FQDN field, enter the value
<code>
mycluster.mydomain.com
</code>
and add the following records in the DNS table for
<code>
mydomain.com
</code>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">mycluster.mydomain.com NS node1.mycluster.mydomain.com
</span></span><span class="line"><span class="cl"> node2.mycluster.mydomain.com
</span></span><span class="line"><span class="cl"> node3.mycluster.mydomain.com
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">node1.mycluster.mydomain.com A 1.1.1.1
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">node2.mycluster.mydomain.com A 2.2.2.2
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">node3.mycluster.mydomain.com A 3.3.3.3
</span></span></code></pre>
</div>
</li>
</ol>
<h3 id="zeroconfiguration-using-mdns-development-option-only">
Zero-configuration using mDNS
</h3>
<p>
Development and test environments can use
<a href="https://en.wikipedia.org/wiki/Multicast_DNS">
Multicast DNS
</a>
(mDNS), a zero-configuration service designed for small networks. Production environments should
<em>
not
</em>
use mDNS.
</p>
<p>
mDNS is a standard protocol that provides DNS-like name resolution and service discovery capabilities
to machines on local networks with minimal to no configuration.
</p>
<p>
Before adopting mDNS, verify that it's supported by each client you wish to use to connect to your Redis databases. Also make sure that your network infrastructure permits mDNS/multi-casting between clients and cluster nodes.
</p>
<p>
Configuring the cluster to support mDNS requires you to assign the cluster a
<code>
.local
</code>
name.
</p>
<p>
For example, if you want to name the Redis Enterprise Software cluster
<code>
rediscluster
</code>
, specify the FQDN name as
<code>
rediscluster.local
</code>
.
</p>
<p>
When using the DNS or mDNS option, failover can be done transparently and the DNS is updated automatically to point to the IP address of the new primary node.
</p>
<h2 id="ip-based-connections">
IP-based connections
</h2>
<p>
When you use the IP-based connection option, the FQDN does not need to have any special format
because clients use IP addresses instead of hostnames to access the databases so you are free to choose whatever name you want.
Using the IP-based connection option does not require any DNS configuration either.
</p>
<p>
To administer the cluster you do need to know the IP address of at least one of the nodes in the cluster.
Once you have the IP address, you can simply connect to port number 8443 (for example:
<a href="https://10.0.0.12:8443">
https://10.0.0.12:8443
</a>
).
However, as the topology of the cluster changes and node with the given IP address is removed,
you need to remember the IP address of another node participating in this cluster to connect to the Cluster Manager UI and manage the cluster.
</p>
<p>
Applications connecting to Redis Software databases have the same constraints.
When using the IP-based connection method, you can use the
<a href="/docs/latest/operate/rs/7.4/databases/durability-ha/discovery-service/">
Discovery Service
</a>
to discover the database endpoint for a given database name as long as you have an IP address for at least one of the nodes in the cluster.
The API used for discovery service is compliant with the Redis Sentinel API.
</p>
<p>
To test your connection, try pinging the service. For help, see
<a href="/docs/latest/operate/rs/7.4/databases/connect/test-client-connectivity/">
Connect to your database
</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/7.4/networking/cluster-dns/"/>
<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/configure/rack-zone-awareness/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Rack-zone awareness in Redis Enterprise Software
</h1>
<p class="text-lg -mt-5 mb-10">
Rack-zone awareness ensures high availability in the event of a rack or zone failure.
</p>
<p>
Rack-zone awareness helps ensure high availability in the event of a rack or zone failure.
</p>
<p>
When you enable rack-zone awareness in a Redis Enterprise Software cluster, you assign
a
<a href="#rack-zone-id-rules">
rack-zone ID
</a>
to each node. This ID is used to map the node to a
physical rack or logical zone. The cluster can then ensure that master shards, corresponding replica shards, and associated endpoints are placed on
<a href="#node-layout-guidelines">
nodes in different racks or zones
</a>
.
</p>
<p>
In the event of a rack or zone failure, the replicas and endpoints in the remaining racks and zones are promoted. This ensures high availability when a rack or zone fails.
</p>
<p>
There is no limitation on the number of racks and zones per cluster. Each
node can belong to a different rack or multiple nodes can belong to the
same rack.
</p>
<p>
Rack-zone awareness affects various cluster, node, and database actions, such as node rebalancing, node removal, node replacement, shard and endpoint migration, and database failover.
</p>
<h2 id="rack-zone-id-rules">
Rack-zone ID rules
</h2>
<p>
The rack-zone ID must comply with the following rules:
</p>
<ul>
<li>
Maximum length of 63 characters.
</li>
<li>
Characters consist of letters, digits, and hyphens ('-'). Underscores ('_') are also accepted as of 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>
.
</li>
<li>
ID starts with a letter and ends with a letter or a digit.
</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>
Rack-zone IDs are
<strong>
case-insensitive
</strong>
(uppercase and lowercase letter are treated as the same).
</div>
</div>
<h2 id="node-layout-guidelines">
Node layout guidelines
</h2>
<p>
Avoid placing the majority of nodes in one availability zone.
</p>
<p>
If a Redis Enterprise Software cluster consists of three nodes (the recommended minimum), follow these guidelines:
</p>
<ul>
<li>
<p>
For high availability, the three nodes must be distributed across three
<em>
distinct
</em>
racks or zones.
</p>
</li>
<li>
<p>
When using availability zones, all three zones should exist within the same
<em>
region
</em>
to avoid potential latency issues.
</p>
</li>
</ul>
<h2 id="set-up-rack-zone-awareness">
Set up rack-zone awareness
</h2>
<p>
To enable rack-zone awareness, you need to configure it for the
cluster, nodes, and
<a href="#enable-database-rack-zone-awareness">
databases
</a>
.
</p>
<h3 id="new-cluster">
New cluster
</h3>
<p>
You can set up rack-zone awareness for the cluster and its nodes during
<a href="/docs/latest/operate/rs/7.4/clusters/new-cluster-setup/">
cluster creation
</a>
:
</p>
<ol>
<li>
<p>
In the
<strong>
Cluster
</strong>
screen's
<strong>
Configuration
</strong>
section, enable
<strong>
Rack zone awareness
</strong>
.
</p>
</li>
<li>
<p>
Select
<strong>
Next
</strong>
to continue to the
<strong>
Node
</strong>
configuration screen.
</p>
</li>
<li>
<p>
Enter a
<strong>
Rack-zone ID
</strong>
for the current node.
</p>
</li>
<li>
<p>
Finish
<a href="/docs/latest/operate/rs/7.4/clusters/new-cluster-setup/">
cluster setup
</a>
.
</p>
</li>
<li>
<p>
For every
<a href="/docs/latest/operate/rs/7.4/clusters/add-node/">
node you add to the cluster
</a>
, assign a different
<strong>
Rack-zone ID
</strong>
.
</p>
</li>
</ol>
<h3 id="existing-cluster">
Existing cluster
</h3>
<p>
If you did not configure rack-zone awareness during cluster creation, you can configure rack-zone awareness for existing clusters using the
<a href="/docs/latest/operate/rs/7.4/references/rest-api/">
REST API
</a>
:
</p>
<ol>
<li>
<p>
For each node in the cluster, assign a different rack-zone ID using the REST API to
<a href="/docs/latest/operate/rs/7.4/references/rest-api/requests/nodes/#put-node">
update the node
</a>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">PUT /v1/nodes/<node-ID>
</span></span><span class="line"><span class="cl"><span class="o">{</span> <span class="s2">"rack_id"</span>: <span class="s2">"rack-zone-ID"</span> <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 the cluster policy
</a>
to enable rack-zone awareness:
</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">"rack_aware"</span>: <span class="nb">true</span> <span class="o">}</span>
</span></span></code></pre>
</div>
</li>
</ol>
<h2 id="enable-database-rack-zone-awareness">
Enable database rack-zone awareness
</h2>
<p>
Before you can enable rack-zone awareness for a database, you must configure rack-zone awareness for the cluster and its nodes. For more information, see
<a href="#set-up-rack-zone-awareness">
set up rack-zone awareness
</a>
.
</p>
<!--
To enable rack-zone awareness for a database using the Cluster Manager UI:
1. From **databases**, [create a new database](/docs/latest/operate/rs/7.4/databases/create/) or edit an existing database's **configuration**.
1. Expand the **High availability & durability** section.
1. Enable [**Replication**](/docs/latest/operate/rs/7.4/databases/durability-ha/replication/).
1. Select **Rack-zone awareness**.
<a href='/docs/latest/images/rs/screenshots/databases/config-rack-zone-awareness.png' sdata-lightbox="/images/rs/screenshots/databases/config-rack-zone-awareness.png">
<img src='/docs/latest/images/rs/screenshots/databases/config-rack-zone-awareness.png'
alt="Select the Rack-zone awareness checkbox to enable rack-zone awareness for the database."
/>
</a>
1. **Create** or **Save** your database.
1. [Rearrange database shards](#rearrange-database-shards) to optimize an existing database for rack-zone awareness.
<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 width="21" height="21" viewBox="0 0 21 21" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5"/>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2"/>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2"/>
</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 enabled rack-zone awareness during database creation, you can ignore this step.</div>
</div>
-->
<p>
To enable rack-zone awareness for a database, use a
<a href="/docs/latest/operate/rs/7.4/references/rest-api/requests/bdbs/#put-bdbs">
REST API request
</a>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">PUT /v1/bdbs/<database-ID>
</span></span><span class="line"><span class="cl"><span class="o">{</span> <span class="s2">"rack_aware"</span>: <span class="nb">true</span> <span class="o">}</span>
</span></span></code></pre>
</div>
<h3 id="rearrange-database-shards">
Rearrange database shards
</h3>
<p>
After you enable rack-zone awareness for an existing database, you should generate an optimized shard placement blueprint using the
<a href="/docs/latest/operate/rs/7.4/references/rest-api/">
REST API
</a>
and use it to rearrange the shards in different racks or zones.
</p>
<ol>
<li>
<p>
<a href="/docs/latest/operate/rs/7.4/references/rest-api/requests/bdbs/actions/optimize_shards_placement/#get-bdbs-actions-optimize-shards-placement">
Generate an optimized shard placement blueprint
</a>
:
</p>
<ol>
<li>
<p>
Send the following
<code>
GET
</code>
request:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">GET /v1/bdbs/<database-ID>/actions/optimize_shards_placement
</span></span></code></pre>
</div>
</li>
<li>
<p>
Copy the
<code>
cluster-state-id
</code>
from the response headers.
</p>
</li>
<li>
<p>
Copy the JSON response body, which represents the new shard placement blueprint.
</p>
</li>
</ol>
</li>
<li>
<p>
<a href="/docs/latest/operate/rs/7.4/references/rest-api/requests/bdbs/actions/optimize_shards_placement/#put-bdbs-rearrange-shards">
Rearrange the database shards
</a>
according to the new shard placement blueprint:
</p>
<ol>
<li>
<p>
In the request headers, include the
<nobr>
<code>
cluster-state-id
</code>
</nobr>
from the
<code>
optimize_shards_placement
</code>
response.
</p>
</li>
<li>
<p>
Add the following JSON in the request body and replace
<nobr>
<code>
<shard placement blueprint>
</code>
</nobr>
with the new blueprint:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl"><span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"shards_blueprint"</span>: <shard placement blueprint>
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span></code></pre>
</div>
</li>
<li>
<p>
Send the following
<code>
PUT
</code>
request to rearrange the shards:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">PUT /v1/bdbs/<database-ID>
</span></span></code></pre>
</div>
</li>
</ol>
</li>
</ol>
<h2 id="shard-placement-without-rack-zone-awareness">
Shard placement without rack-zone awareness
</h2>
<p>
Even if a database has rack-zone awareness turned off, the cluster still ensures that master and replica shards are placed on distinct nodes.
</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/clusters/configure/rack-zone-awareness/"/>
<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-stream-example/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Write to a Redis stream
</h1>
<p>
In the example below, data is captured from the source table named
<code>
invoice
</code>
and is written to a Redis stream. 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>
When writing to streams, you can use the optional parameter
<code>
mapping
</code>
to limit the number of fields sent in a message and to provide aliases for them. If you don't use the
<code>
mapping
</code>
parameter, all fields captured in the source will be passed as the message payload.
</p>
<p>
Note that streams are different from other data structures because existing messages are never updated or deleted. Any operation in the source will generate a new message with the corresponding operation code (
<code>
op_code
</code>
field) that is automatically added to the message payload.
</p>
<p>
In this case, the result will be a Redis stream with the name based on the key expression (for example,
<code>
invoice:events
</code>
) and with an expiration of 100 seconds for the whole stream. If you don't supply an
<code>
expire
</code>
parameter, the keys will never expire.
</p>
<p>
In the example, only three original fields are passed in the message payload:
<code>
InvoiceId
</code>
(as
<code>
message_id
</code>
),
<code>
BillingCountry
</code>
(as
<code>
country
</code>
),
<code>
Total
</code>
(as
<code>
Total
</code>
, no alias provided) and
<code>
op_code
</code>
, which is implicitly added to all messages sent to streams.
</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">stream</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="s2">"`invoice:events`"</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">mapping</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">InvoiceId</span><span class="p">:</span><span class="w"> </span><span class="l">message_id</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">BillingCountry</span><span class="p">:</span><span class="w"> </span><span class="l">country</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="l">Total</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-stream-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/references/rest-api/requests/bdbs/passwords/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Database passwords requests
</h1>
<p class="text-lg -mt-5 mb-10">
Database password requests
</p>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="#put-bdbs-password">
PUT
</a>
</td>
<td>
<code>
/v1/bdbs/{uid}/passwords
</code>
</td>
<td>
Update database password
</td>
</tr>
<tr>
<td>
<a href="#post-bdbs-password">
POST
</a>
</td>
<td>
<code>
/v1/bdbs/{uid}/passwords
</code>
</td>
<td>
Add database password
</td>
</tr>
<tr>
<td>
<a href="#delete-bdbs-password">
DELETE
</a>
</td>
<td>
<code>
/v1/bdbs/{uid}/passwords
</code>
</td>
<td>
Delete database password
</td>
</tr>
</tbody>
</table>
<h2 id="put-bdbs-password">
Update database password
</h2>
<pre><code>PUT /v1/bdbs/{int: uid}/passwords
</code></pre>
<p>
Set a single password for the bdb's default user (i.e., for
<code>
AUTH
</code>
<code>
<password>
</code>
authentications).
</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/#update_bdb">
update_bdb
</a>
</td>
</tr>
</tbody>
</table>
<h3 id="put-request">
Request
</h3>
<h4 id="example-http-request">
Example HTTP request
</h4>
<pre><code>PUT /bdbs/1/passwords
</code></pre>
<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">"password"</span><span class="p">:</span> <span class="s2">"new password"</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<p>
The above request resets the password of the bdb to βnew passwordβ.
</p>
<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>
<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 to update the password.
</td>
</tr>
</tbody>
</table>
<h4 id="request-body">
Request body
</h4>
<table>
<thead>
<tr>
<th>
Field
</th>
<th>
Type
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
password
</td>
<td>
string
</td>
<td>
New password
</td>
</tr>
</tbody>
</table>
<h3 id="put-response">
Response
</h3>
<p>
Returns a status code that indicates password update success or failure.
</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>
The password was changed.
</td>
</tr>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5">
404 Not Found
</a>
</td>
<td>
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>
Invalid configuration parameters provided.
</td>
</tr>
</tbody>
</table>
<h2 id="post-bdbs-password">
Add database password
</h2>
<pre><code>POST /v1/bdbs/{int: uid}/passwords
</code></pre>
<p>
Add a password to the bdb's default user (i.e., for
<code>
AUTH
</code>
<code>
<password>
</code>
authentications).
</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/#update_bdb">
update_bdb
</a>
</td>
</tr>
</tbody>
</table>
<h3 id="post-request">
Request
</h3>
<h4 id="example-http-request-1">
Example HTTP request
</h4>
<pre><code>POST /bdbs/1/passwords
</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">"password"</span><span class="p">:</span> <span class="s2">"password to add"</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<p>
The above request adds a password to the bdb.
</p>
<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>
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-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 add password.
</td>
</tr>
</tbody>
</table>
<h4 id="request-body-1">
Request body
</h4>
<table>
<thead>
<tr>
<th>
Field
</th>
<th>
Type
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
password
</td>
<td>
string
</td>
<td>
Password to add
</td>
</tr>
</tbody>
</table>
<h3 id="post-response">
Response
</h3>
<p>
Returns a status code that indicates password creation success or failure.
</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 password was added.
</td>
</tr>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5">
404 Not Found
</a>
</td>
<td>
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>
Invalid configuration parameters provided.
</td>
</tr>
</tbody>
</table>
<h2 id="delete-bdbs-password">
Delete database password
</h2>
<pre><code>DELETE /v1/bdbs/{int: uid}/passwords
</code></pre>
<p>
Delete a password from the bdb's default user (i.e., for
<code>
AUTH
</code>
<code>
<password>
</code>
authentications).
</p>
<h4 id="required-permissions-2">
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/#update_bdb">
update_bdb
</a>
</td>
</tr>
</tbody>
</table>
<h3 id="delete-request">
Request
</h3>
<h4 id="example-http-request-2">
Example HTTP request
</h4>
<pre><code>DELETE /bdbs/1/passwords
</code></pre>
<h4 id="example-json-body-2">
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">"password"</span><span class="p">:</span> <span class="s2">"password to delete"</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<p>
The above request deletes a password from the bdb.
</p>
<h4 id="request-headers-2">
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>
<h4 id="url-parameters-2">
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 delete password.
</td>
</tr>
</tbody>
</table>
<h4 id="request-body-2">
Request body
</h4>
<table>
<thead>
<tr>
<th>
Field
</th>
<th>
Type
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
password
</td>
<td>
string
</td>
<td>
Password to delete
</td>
</tr>
</tbody>
</table>
<h3 id="delete-response">
Response
</h3>
<p>
Returns a status code that indicates password deletion success or failure.
</p>
<h3 id="delete-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 password was deleted.
</td>
</tr>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5">
404 Not Found
</a>
</td>
<td>
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>
Invalid configuration parameters provided.
</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/passwords/"/>
<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.arrtrim/.html | <section class="prose w-full py-12">
<h1 class="command-name">
JSON.ARRTRIM
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">JSON.ARRTRIM key path start stop</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(N) when path is evaluated to a single value where N is the size of the array, O(N) when path is evaluated to multiple values, where N is the size of the key
</dd>
</dl>
<p>
Trim an array so that it contains only the specified inclusive range of elements
</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 to modify.
</p>
</details>
<h2 id="optional-arguments">
Optional arguments
</h2>
<details open="">
<summary>
<code>
path
</code>
</summary>
<p>
is JSONPath to specify. Default is root
<code>
$
</code>
.
</p>
</details>
<details open="">
<summary>
<code>
start
</code>
</summary>
<p>
is index of the first element to keep (previous elements are trimmed). Default is 0.
</p>
</details>
<details open="">
<summary>
<code>
stop
</code>
</summary>
<p>
is the index of the last element to keep (following elements are trimmed), including the last element. Default is 0. Negative values are interpreted as starting from the end.
</p>
</details>
<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">
About out-of-range indexes:
</div>
<p>
JSON.ARRTRIM is extremely forgiving, and using it with out-of-range indexes does not produce an error. Note a few differences between how RedisJSON v2.0 and legacy versions handle out-of-range indexes.
</p>
<p>
Behavior as of RedisJSON v2.0:
</p>
<ul>
<li>
If
<code>
start
</code>
is larger than the array's size or
<code>
start
</code>
>
<code>
stop
</code>
, returns 0 and an empty array.
</li>
<li>
If
<code>
start
</code>
is < 0, then start from the end of the array.
</li>
<li>
If
<code>
stop
</code>
is larger than the end of the array, it is treated like the last element.
</li>
</ul>
</div>
</div>
<h2 id="return">
Return
</h2>
<p>
JSON.ARRTRIM returns an array of integer replies for each path, the array's new size, or
<code>
nil
</code>
, if the matching JSON value is not an array.
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>
Trim an array to a specific set of values
</b>
</summary>
<p>
Create two headphone products with maximum sound levels.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> JSON.SET key $
</span></span><span class="line"><span class="cl"><span class="s2">"[[{\"name\":\"Healthy headphones\",\"description\":\"Wireless Bluetooth headphones with noise-cancelling technology\",\"connection\":{\"wireless\":true,\"type\":\"Bluetooth\"},\"price\":99.98,\"stock\":25,\"colors\":[\"black\",\"silver\"],\"max_level\":[60,70,80]},{\"name\":\"Noisy headphones\",\"description\":\"Wireless Bluetooth headphones with noise-cancelling technology\",\"connection\":{\"wireless\":true,\"type\":\"Bluetooth\"},\"price\":99.98,\"stock\":25,\"colors\":[\"black\",\"silver\"],\"max_level\":[85,90,100,120]}]]"</span>
</span></span><span class="line"><span class="cl">OK</span></span></code></pre>
</div>
<p>
Add new sound level values to the second product.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> JSON.ARRAPPEND key $.<span class="o">[</span>1<span class="o">]</span>.max_level <span class="m">140</span> <span class="m">160</span> <span class="m">180</span> <span class="m">200</span> <span class="m">220</span> <span class="m">240</span> <span class="m">260</span> <span class="m">280</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">12</span></span></span></code></pre>
</div>
<p>
Get the updated array.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> JSON.GET key $.<span class="o">[</span>1<span class="o">]</span>.max_level
</span></span><span class="line"><span class="cl"><span class="s2">"[[85,90,100,120,140,160,180,200,220,240,260,280]]"</span></span></span></code></pre>
</div>
<p>
Keep only the values between the fifth and the ninth element, inclusive of that last element.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> JSON.ARRTRIM key $.<span class="o">[</span>1<span class="o">]</span>.max_level <span class="m">4</span> <span class="m">8</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">5</span></span></span></code></pre>
</div>
<p>
Get the updated array.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> JSON.GET key $.<span class="o">[</span>1<span class="o">]</span>.max_level
</span></span><span class="line"><span class="cl"><span class="s2">"[[140,160,180,200,220]]"</span></span></span></code></pre>
</div>
</details>
<h2 id="see-also">
See also
</h2>
<p>
<a href="/docs/latest/commands/json.arrindex/">
<code>
JSON.ARRINDEX
</code>
</a>
|
<a href="/docs/latest/commands/json.arrinsert/">
<code>
JSON.ARRINSERT
</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.arrtrim/"/>
<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.syndump.html | <section class="prose w-full py-12">
<h1 class="command-name">
FT.SYNDUMP
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">FT.SYNDUMP index
</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.2.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>
Dump the contents of a synonym group
</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.
</p>
</details>
<p>
Use FT.SYNDUMP to dump the synonyms data structure. This command returns a list of synonym terms and their synonym group ids.
</p>
<h2 id="return">
Return
</h2>
<p>
FT.SYNDUMP returns an array reply, with a pair of
<code>
term
</code>
and an array of synonym groups.
</p>
<h2 id="examples">
Examples
</h2>
<details open="">
<summary>
<b>
Return the contents of a synonym group
</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> FT.SYNDUMP idx
</span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="s2">"shalom"</span>
</span></span><span class="line"><span class="cl">2<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"synonym1"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"synonym2"</span>
</span></span><span class="line"><span class="cl">3<span class="o">)</span> <span class="s2">"hi"</span>
</span></span><span class="line"><span class="cl">4<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"synonym1"</span>
</span></span><span class="line"><span class="cl">5<span class="o">)</span> <span class="s2">"hello"</span>
</span></span><span class="line"><span class="cl">6<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"synonym1"</span></span></span></code></pre>
</div>
</details>
<h2 id="see-also">
See also
</h2>
<p>
<a href="/docs/latest/commands/ft.synupdate/">
<code>
FT.SYNUPDATE
</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.syndump/"/>
<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/advanced-concepts/aggregations.html | <section class="prose w-full py-12">
<h1>
Aggregations
</h1>
<p class="text-lg -mt-5 mb-10">
Groupings, projections, and aggregation functions
</p>
<p>
Aggregations are a way to process the results of a search query. Aggregation allows you to group, sort, and transform your result data, and to extract analytic insights from it. Much like aggregation queries in other databases and search engines, they can be used to create analytics reports, or perform
<a href="https://en.wikipedia.org/wiki/Faceted_search">
faceted search
</a>
style queries.
</p>
<p>
For example, indexing a web-server's logs, you can create a report for unique users by hour, country, or any other breakdown. Or you can create different reports for errors, warnings, etc.
</p>
<h2 id="core-concepts">
Core concepts
</h2>
<p>
The basic idea of an aggregate query is this:
</p>
<ul>
<li>
Perform a search query, filtering for records you wish to process.
</li>
<li>
Build a pipeline of operations that transform the results by zero or more sequences of:
<ul>
<li>
<strong>
Group and reduce
</strong>
: grouping by fields in the results, and applying reducer functions to each group.
</li>
<li>
<strong>
Sort
</strong>
: sort the results based on one or more fields.
</li>
<li>
<strong>
Apply transformations
</strong>
: apply mathematical and string functions on fields in the pipeline, optionally creating new fields or replacing existing ones.
</li>
<li>
<strong>
Limit
</strong>
: limit the result, regardless of how the result is sorted.
</li>
<li>
<strong>
Filter
</strong>
: filter the results (post-query) based on predicates relating to its values.
</li>
</ul>
</li>
</ul>
<p>
The pipeline is dynamic and re-entrant, and every operation can be repeated. For example, you can group by property X, sort the top 100 results by group size, then group by property Y and sort the results by some other property, then apply a transformation on the output.
</p>
<p>
Figure 1: Aggregation Pipeline Example
</p>
<img src="../../img/pipeline.png"/>
<h2 id="aggregate-request-format">
Aggregate request format
</h2>
<p>
The aggregate request's syntax is defined as follows:
</p>
<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="k">AGGREGATE</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="err">{</span><span class="n">index_name</span><span class="p">:</span><span class="n">string</span><span class="err">}</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="err">{</span><span class="n">query_string</span><span class="p">:</span><span class="n">string</span><span class="err">}</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="p">[</span><span class="n">VERBATIM</span><span class="p">]</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="p">[</span><span class="k">LOAD</span><span class="w"> </span><span class="err">{</span><span class="n">nargs</span><span class="p">:</span><span class="nb">integer</span><span class="err">}</span><span class="w"> </span><span class="err">{</span><span class="n">property</span><span class="p">:</span><span class="n">string</span><span class="err">}</span><span class="w"> </span><span class="p">...]</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="p">[</span><span class="n">GROUPBY</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="err">{</span><span class="n">nargs</span><span class="p">:</span><span class="nb">integer</span><span class="err">}</span><span class="w"> </span><span class="err">{</span><span class="n">property</span><span class="p">:</span><span class="n">string</span><span class="err">}</span><span class="w"> </span><span class="p">...</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="n">REDUCE</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="err">{</span><span class="n">FUNC</span><span class="p">:</span><span class="n">string</span><span class="err">}</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="err">{</span><span class="n">nargs</span><span class="p">:</span><span class="nb">integer</span><span class="err">}</span><span class="w"> </span><span class="err">{</span><span class="n">arg</span><span class="p">:</span><span class="n">string</span><span class="err">}</span><span class="w"> </span><span class="p">...</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="p">[</span><span class="k">AS</span><span class="w"> </span><span class="err">{</span><span class="n">name</span><span class="p">:</span><span class="n">string</span><span class="err">}</span><span class="p">]</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="p">...</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">...</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="p">[</span><span class="n">SORTBY</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="err">{</span><span class="n">nargs</span><span class="p">:</span><span class="nb">integer</span><span class="err">}</span><span class="w"> </span><span class="err">{</span><span class="n">string</span><span class="err">}</span><span class="w"> </span><span class="p">...</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="p">[</span><span class="k">MAX</span><span class="w"> </span><span class="err">{</span><span class="n">num</span><span class="p">:</span><span class="nb">integer</span><span class="err">}</span><span class="p">]</span><span class="w"> </span><span class="p">...</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">...</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="p">[</span><span class="n">APPLY</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="err">{</span><span class="n">EXPR</span><span class="p">:</span><span class="n">string</span><span class="err">}</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="k">AS</span><span class="w"> </span><span class="err">{</span><span class="n">name</span><span class="p">:</span><span class="n">string</span><span class="err">}</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">...</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="p">[</span><span class="n">FILTER</span><span class="w"> </span><span class="err">{</span><span class="n">EXPR</span><span class="p">:</span><span class="n">string</span><span class="err">}</span><span class="p">]</span><span class="w"> </span><span class="p">...</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="p">[</span><span class="k">LIMIT</span><span class="w"> </span><span class="err">{</span><span class="k">offset</span><span class="p">:</span><span class="nb">integer</span><span class="err">}</span><span class="w"> </span><span class="err">{</span><span class="n">num</span><span class="p">:</span><span class="nb">integer</span><span class="err">}</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">...</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="p">[</span><span class="n">PARAMS</span><span class="w"> </span><span class="err">{</span><span class="n">nargs</span><span class="err">}</span><span class="w"> </span><span class="err">{</span><span class="n">name</span><span class="err">}</span><span class="w"> </span><span class="err">{</span><span class="n">value</span><span class="err">}</span><span class="w"> </span><span class="p">...</span><span class="w"> </span><span class="p">]</span><span class="w">
</span></span></span></code></pre>
</div>
<h3 id="parameters-in-detail">
Parameters in detail
</h3>
<p>
Parameters that can take a variable number of arguments are expressed in the
form of
<code>
param {nargs} {property_1... property_N}
</code>
. The first argument to the
parameter is the number of arguments following the parameter. This allows
Redis Stack to avoid a parsing ambiguity in case one of your arguments has the
name of another parameter. For example, to sort by first name, last name, and
country, one would specify
<code>
SORTBY 6 firstName ASC lastName DESC country ASC
</code>
.
</p>
<ul>
<li>
<p>
<strong>
index_name
</strong>
: The index the query is executed against.
</p>
</li>
<li>
<p>
<strong>
query_string
</strong>
: The base filtering query that retrieves the documents. It follows the exact same syntax as the search query, including filters, unions, not, optional, etc.
</p>
</li>
<li>
<p>
<strong>
LOAD {nargs} {property} ...
</strong>
: Load document fields from the document HASH objects. This should be avoided as a general rule of thumb. Fields needed for aggregations should be stored as SORTABLE (and optionally UNF to avoid any normalization), where they are available to the aggregation pipeline with very low latency. LOAD hurts the performance of aggregate queries considerably since every processed record needs to execute the equivalent of HMGET against a Redis key, which when executed over millions of keys, amounts to very high processing times.
The document ID can be loaded using
<code>
@__key
</code>
.
</p>
</li>
<li>
<p>
<strong>
GROUPBY {nargs} {property} ...
</strong>
: Group the results in the pipeline based on one or more properties. Each group should have at least one reducer (See below), a function that handles the group entries, either counting them or performing multiple aggregate operations (see below).
</p>
</li>
<li>
<p>
<strong>
REDUCE {func} {nargs} {arg} ... [AS {name}]
</strong>
: Reduce the matching results in each group into a single record, using a reduction function. For example, COUNT will count the number of records in the group. See the Reducers section below for more details on available reducers.
</p>
<p>
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 COUNT_DISTINCT by property
<code>
@foo
</code>
, the resulting name will be
<code>
count_distinct(@foo)
</code>
.
</p>
</li>
<li>
<p>
<strong>
SORTBY {nargs} {property} {ASC|DESC} [MAX {num}]
</strong>
: Sort the pipeline up until the point of SORTBY, using a list of properties. By default, sorting is ascending, but
<code>
ASC
</code>
or
<code>
DESC
</code>
can be added for each property.
<code>
nargs
</code>
is the number of sorting parameters, including ASC and DESC. for example:
<code>
SORTBY 4 @foo ASC @bar DESC
</code>
.
</p>
<p>
<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.
</p>
</li>
<li>
<p>
<strong>
APPLY {expr} AS {name}
</strong>
: Apply a one-to-one transformation on one or more properties, and either store the result as a new property down the pipeline, or replace any property using this transformation.
<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>
will evaluate this expression dynamically for each record in the pipeline and store the result as a new property called baz, that can be referenced by further APPLY / SORTBY / GROUPBY / REDUCE operations down the pipeline.
</p>
</li>
<li>
<p>
<strong>
LIMIT {offset} {num}
</strong>
. Limit the number of results to return just
<code>
num
</code>
results starting at index
<code>
offset
</code>
(zero based). AS mentioned above, it is much more efficient to use
<code>
SORTBY β¦ MAX
</code>
if you are interested in just limiting the output of a sort operation.
</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 MAX from SORTBY will result in the pipeline sorting all the records and then paging over results 50-100.
</p>
</li>
<li>
<p>
<strong>
FILTER {expr}
</strong>
. Filter the results using predicate expressions relating to values in each result. The expressions are applied post-query and relate to the current state of the pipeline. See FILTER Expressions below for full details.
</p>
</li>
<li>
<p>
<strong>
PARAMS {nargs} {name} {value}
</strong>
. Define one or more value parameters. Each parameter has a name and a value. Parameters can be referenced in the query string by a
<code>
$
</code>
, followed by the parameter name, e.g.,
<code>
$user
</code>
, and 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>
would be evaluated to
<code>
@loc:[29.69465 34.95126 10 km]
</code>
. Parameters cannot be referenced in the query string where concrete values are not allowed, such as in field names, e.g.,
<code>
@loc
</code>
</p>
</li>
<li>
</li>
</ul>
<h2 id="example">
Example
</h2>
<p>
A log of visits to a website might look like the following, each record of which has the following fields/properties:
</p>
<ul>
<li>
<strong>
url
</strong>
(text, sortable)
</li>
<li>
<strong>
timestamp
</strong>
(numeric, sortable) - Unix timestamp of visit entry.
</li>
<li>
<strong>
country
</strong>
(tag, sortable)
</li>
<li>
<strong>
user_id
</strong>
(text, sortable, not indexed)
</li>
</ul>
<h3 id="example-1-unique-users-by-hour-ordered-chronologically">
Example 1: unique users by hour, ordered chronologically.
</h3>
<p>
The first step is to determine the index name and the filtering query. A filter query of
<code>
*
</code>
means "get all records":
</p>
<pre tabindex="0"><code>FT.AGGREGATE myIndex "*"
</code></pre>
<p>
Next, group the results by hour. The data contains visit times as unix timestamps in second resolution, so you'll need to extract the hour component of the timestamp. To do so, add an APPLY step that strips the sub-hour information from the timestamp and stores is as a new property,
<code>
hour
</code>
:
</p>
<pre tabindex="0"><code>FT.AGGREGATE myIndex "*"
APPLY "@timestamp - (@timestamp % 3600)" AS hour
</code></pre>
<p>
Next, group the results by hour and count the distinct user ids in each hour. This is done by a GROUPBY/REDUCE step:
</p>
<pre tabindex="0"><code>FT.AGGREGATE myIndex "*"
APPLY "@timestamp - (@timestamp % 3600)" AS hour
GROUPBY 1 @hour
REDUCE COUNT_DISTINCT 1 @user_id AS num_users
</code></pre>
<p>
Next, sort the results by hour, ascending:
</p>
<pre tabindex="0"><code>FT.AGGREGATE myIndex "*"
APPLY "@timestamp - (@timestamp % 3600)" AS hour
GROUPBY 1 @hour
REDUCE COUNT_DISTINCT 1 @user_id AS num_users
SORTBY 2 @hour ASC
</code></pre>
<p>
And as a final step, format the hour as a human readable timestamp. This is done by calling the transformation function
<code>
timefmt
</code>
that formats Unix timestamps. You can specify a format to be passed to the system's
<code>
strftime
</code>
function (
<a href="https://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html">
see documentation
</a>
), but not specifying one is equivalent to specifying
<code>
%FT%TZ
</code>
to
<code>
strftime
</code>
.
</p>
<pre tabindex="0"><code>FT.AGGREGATE myIndex "*"
APPLY "@timestamp - (@timestamp % 3600)" AS hour
GROUPBY 1 @hour
REDUCE COUNT_DISTINCT 1 @user_id AS num_users
SORTBY 2 @hour ASC
APPLY timefmt(@hour) AS hour
</code></pre>
<h3 id="example-2-sort-visits-to-a-specific-url-by-day-and-country">
Example 2: Sort visits to a specific URL by day and country:
</h3>
<p>
The next example filters by the url, transforms the timestamp to its day part, and groups by the day and country, counting the number of visits per group, sorting by day ascending and country descending.
</p>
<pre tabindex="0"><code>FT.AGGREGATE myIndex "@url:\"about.html\""
APPLY "@timestamp - (@timestamp % 86400)" AS day
GROUPBY 2 @day @country
REDUCE count 0 AS num_visits
SORTBY 4 @day ASC @country DESC
</code></pre>
<h2 id="groupby-reducers">
GROUPBY reducers
</h2>
<p>
<code>
GROUPBY
</code>
works similarly to SQL
<code>
GROUP BY
</code>
clauses, and creates groups of results based on one or more properties in each record. For each group, Redis returns the group keys, or the values common to all records in the group, and the results of zero or more
<code>
REDUCE
</code>
clauses.
</p>
<p>
Each
<code>
GROUPBY
</code>
step in the pipeline may be accompanied by zero or more
<code>
REDUCE
</code>
clauses. Reducers apply an accumulation function to each record in the group and reduces them into a single record representing the group. When the processing is complete, all the records upstream of the
<code>
GROUPBY
</code>
step emit their reduced record.
</p>
<p>
For example, the simplest reducer is COUNT, which simply counts the number of records in each group.
</p>
<p>
If multiple
<code>
REDUCE
</code>
clauses exist for a single
<code>
GROUPBY
</code>
step, each reducer works independently on each result and writes its final output once. Each reducer may have its own alias determined using the
<code>
AS
</code>
optional parameter. If
<code>
AS
</code>
is not specified, the alias is the reduce function and its parameters, e.g.
<code>
count_distinct(foo,bar)
</code>
.
</p>
<h3 id="supported-groupby-reducers">
Supported GROUPBY reducers
</h3>
<h4 id="count">
COUNT
</h4>
<p>
<strong>
Format
</strong>
</p>
<pre tabindex="0"><code>REDUCE COUNT 0
</code></pre>
<p>
<strong>
Description
</strong>
</p>
<p>
Count the number of records in each group
</p>
<h4 id="count_distinct">
COUNT_DISTINCT
</h4>
<p>
<strong>
Format
</strong>
</p>
<pre tabindex="0"><code>REDUCE COUNT_DISTINCT 1 {property}
</code></pre>
<p>
<strong>
Description
</strong>
</p>
<p>
Count the number of distinct values for
<code>
property
</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>
The reducer creates a hash-set per group, and hashes each record. This can be memory heavy if the groups are big.
</div>
</div>
<h4 id="count_distinctish">
COUNT_DISTINCTISH
</h4>
<p>
<strong>
Format
</strong>
</p>
<pre tabindex="0"><code>REDUCE COUNT_DISTINCTISH 1 {property}
</code></pre>
<p>
<strong>
Description
</strong>
</p>
<p>
Same as COUNT_DISTINCT, provides an approximation instead of an exact count, which consumes less memory and CPU for big groups.
</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 reducer uses
<a href="https://en.wikipedia.org/wiki/HyperLogLog">
HyperLogLog
</a>
counters per group, at ~3% error rate, and 1024 bytes of constant space per group. This means it is ideal for a few huge groups and not ideal for many small groups. In the former case, it can be an order of magnitude faster and consume much less memory than COUNT_DISTINCT, but again, it does not fit every use case.
</div>
</div>
<h4 id="sum">
SUM
</h4>
<p>
<strong>
Format
</strong>
</p>
<pre tabindex="0"><code>REDUCE SUM 1 {property}
</code></pre>
<p>
<strong>
Description
</strong>
</p>
<p>
Return the sum of all numeric values of a given property in a group. Non-numeric values in the group are counted as 0.
</p>
<h4 id="min">
MIN
</h4>
<p>
<strong>
Format
</strong>
</p>
<pre tabindex="0"><code>REDUCE MIN 1 {property}
</code></pre>
<p>
<strong>
Description
</strong>
</p>
<p>
Return the minimal value of a property, whether it is a string, number, or NULL.
</p>
<h4 id="max">
MAX
</h4>
<p>
<strong>
Format
</strong>
</p>
<pre tabindex="0"><code>REDUCE MAX 1 {property}
</code></pre>
<p>
<strong>
Description
</strong>
</p>
<p>
Return the maximal value of a property, whether it is a string, number or NULL.
</p>
<h4 id="avg">
AVG
</h4>
<p>
<strong>
Format
</strong>
</p>
<pre tabindex="0"><code>REDUCE AVG 1 {property}
</code></pre>
<p>
<strong>
Description
</strong>
</p>
<p>
Return the average value of a numeric property. This is equivalent to reducing by sum and count, and later, applying the ratio of them as an APPLY step.
</p>
<h4 id="stddev">
STDDEV
</h4>
<p>
<strong>
Format
</strong>
</p>
<pre tabindex="0"><code>REDUCE STDDEV 1 {property}
</code></pre>
<p>
<strong>
Description
</strong>
</p>
<p>
Return the
<a href="https://en.wikipedia.org/wiki/Standard_deviation">
standard deviation
</a>
of a numeric property in the group.
</p>
<h4 id="quantile">
QUANTILE
</h4>
<p>
<strong>
Format
</strong>
</p>
<pre tabindex="0"><code>REDUCE QUANTILE 2 {property} {quantile}
</code></pre>
<p>
<strong>
Description
</strong>
</p>
<p>
Return the value of a numeric property at a given quantile of the results. Quantile is expressed as a number between 0 and 1. For example, the median can be expressed as the quantile at 0.5, e.g.
<code>
REDUCE QUANTILE 2 @foo 0.5 AS median
</code>
.
</p>
<p>
If multiple quantiles are required, just repeat the QUANTILE reducer for each quantile. For example,
<code>
REDUCE QUANTILE 2 @foo 0.5 AS median REDUCE QUANTILE 2 @foo 0.99 AS p99
</code>
.
</p>
<h4 id="tolist">
TOLIST
</h4>
<p>
<strong>
Format
</strong>
</p>
<pre tabindex="0"><code>REDUCE TOLIST 1 {property}
</code></pre>
<p>
<strong>
Description
</strong>
</p>
<p>
Merge all distinct values of a given property into a single array.
</p>
<h4 id="first_value">
FIRST_VALUE
</h4>
<p>
<strong>
Format
</strong>
</p>
<pre tabindex="0"><code>REDUCE FIRST_VALUE {nargs} {property} [BY {property} [ASC|DESC]]
</code></pre>
<p>
<strong>
Description
</strong>
</p>
<p>
Return the first or top value of a given property in the group, optionally by comparing it to another property. For example, you can extract the name of the oldest user in the group:
</p>
<pre tabindex="0"><code>REDUCE FIRST_VALUE 4 @name BY @age DESC
</code></pre>
<p>
If no
<code>
BY
</code>
is specified, the first value encountered in the group is returned.
</p>
<p>
If you wish to get the top or bottom value in the group sorted by the same value, you are better off using the
<code>
MIN/MAX
</code>
reducers, but the same effect will be achieved by doing
<code>
REDUCE FIRST_VALUE 4 @foo BY @foo DESC
</code>
.
</p>
<h4 id="random_sample">
RANDOM_SAMPLE
</h4>
<p>
<strong>
Format
</strong>
</p>
<pre tabindex="0"><code>REDUCE RANDOM_SAMPLE {nargs} {property} {sample_size}
</code></pre>
<p>
<strong>
Description
</strong>
</p>
<p>
Perform a reservoir sampling of the group elements with a given size, and return an array of the sampled items with an even distribution.
</p>
<h2 id="apply-expressions">
APPLY expressions
</h2>
<p>
<code>
APPLY
</code>
performs a one-to-one transformation on one or more properties in each record. It either stores the result as a new property down the pipeline, or replaces any property using this transformation.
</p>
<p>
The transformations are expressed as a combination of arithmetic expressions and built in functions. Evaluating functions and expressions is recursively nested and can be composed without limit. For example:
<code>
sqrt(log(foo) * floor(@bar/baz)) + (3^@qaz % 6)
</code>
or simply
<code>
@foo/@bar
</code>
.
</p>
<p>
If an expression or a function is applied to values that do not match the expected types, no error is emitted and a NULL value is set as the result.
</p>
<p>
APPLY steps must have an explicit alias determined by the
<code>
AS
</code>
parameter.
</p>
<h3 id="literals-inside-expressions">
Literals inside expressions
</h3>
<ul>
<li>
Numbers are expressed as integers or floating point numbers, e.g.,
<code>
2
</code>
,
<code>
3.141
</code>
, and
<code>
-34
</code>
.
<code>
inf
</code>
and
<code>
-inf
</code>
are acceptable as well.
</li>
<li>
Strings are quoted with either single or double quotes. Single quotes are acceptable inside strings quoted with double quotes and vice versa. Punctuation marks can be escaped with backslashes. e.g.
<code>
"foo's bar"
</code>
,
<code>
'foo\'s bar'
</code>
,
<code>
"foo \"bar\""
</code>
.
</li>
<li>
Any literal or sub-expression can be wrapped in parentheses to resolve ambiguities of operator precedence.
</li>
</ul>
<h3 id="arithmetic-operations">
Arithmetic operations
</h3>
<p>
For numeric expressions and properties, addition (
<code>
+
</code>
), subtraction (
<code>
-
</code>
), multiplication (
<code>
*
</code>
), division (
<code>
/
</code>
), modulo (
<code>
%
</code>
), and power (
<code>
^
</code>
) are supported. Bitwise logical operators are not supported.
</p>
<p>
Note that these operators apply only to numeric values and numeric sub-expressions. Any attempt to multiply a string by a number, for instance, will result in a NULL output.
</p>
<h3 id="list-of-field-apply-functions">
List of field APPLY functions
</h3>
<table>
<thead>
<tr>
<th>
Function
</th>
<th>
Description
</th>
<th>
Example
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
exists(s)
</td>
<td>
Checks whether a field exists in a document.
</td>
<td>
<code>
exists(@field)
</code>
</td>
</tr>
</tbody>
</table>
<h3 id="list-of-numeric-apply-functions">
List of numeric APPLY functions
</h3>
<table>
<thead>
<tr>
<th>
Function
</th>
<th>
Description
</th>
<th>
Example
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
log(x)
</td>
<td>
Return the logarithm of a number, property or subexpression
</td>
<td>
<code>
log(@foo)
</code>
</td>
</tr>
<tr>
<td>
abs(x)
</td>
<td>
Return the absolute number of a numeric expression
</td>
<td>
<code>
abs(@foo-@bar)
</code>
</td>
</tr>
<tr>
<td>
ceil(x)
</td>
<td>
Round to the smallest value not less than x
</td>
<td>
<code>
ceil(@foo/3.14)
</code>
</td>
</tr>
<tr>
<td>
floor(x)
</td>
<td>
Round to largest value not greater than x
</td>
<td>
<code>
floor(@foo/3.14)
</code>
</td>
</tr>
<tr>
<td>
log2(x)
</td>
<td>
Return the logarithm of x to base 2
</td>
<td>
<code>
log2(2^@foo)
</code>
</td>
</tr>
<tr>
<td>
exp(x)
</td>
<td>
Return the exponent of x, e.g.,
<code>
e^x
</code>
</td>
<td>
<code>
exp(@foo)
</code>
</td>
</tr>
<tr>
<td>
sqrt(x)
</td>
<td>
Return the square root of x
</td>
<td>
<code>
sqrt(@foo)
</code>
</td>
</tr>
</tbody>
</table>
<h3 id="list-of-string-apply-functions">
List of string APPLY functions
</h3>
<table>
<thead>
<tr>
<th>
Function
</th>
<th>
</th>
<th>
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
upper(s)
</td>
<td>
Return the uppercase conversion of s
</td>
<td>
<code>
upper('hello world')
</code>
</td>
</tr>
<tr>
<td>
lower(s)
</td>
<td>
Return the lowercase conversion of s
</td>
<td>
<code>
lower("HELLO WORLD")
</code>
</td>
</tr>
<tr>
<td>
startswith(s1,s2)
</td>
<td>
Return
<code>
1
</code>
if s2 is the prefix of s1,
<code>
0
</code>
otherwise.
</td>
<td>
<code>
startswith(@field, "company")
</code>
</td>
</tr>
<tr>
<td>
contains(s1,s2)
</td>
<td>
Return the number of occurrences of s2 in s1,
<code>
0
</code>
otherwise. If s2 is an empty string, return
<code>
length(s1) + 1
</code>
.
</td>
<td>
<code>
contains(@field, "pa")
</code>
</td>
</tr>
<tr>
<td>
strlen(s)
</td>
<td>
Return the length of s
</td>
<td>
<code>
strlen(@t)
</code>
</td>
</tr>
<tr>
<td>
substr(s, offset, count)
</td>
<td>
Return the substring of s, starting at
<em>
offset
</em>
and having
<em>
count
</em>
characters.
<br/>
If offset is negative, it represents the distance from the end of the string.
<br/>
If count is -1, it means "the rest of the string starting at offset".
</td>
<td>
<code>
substr("hello", 0, 3)
</code>
<br/>
<code>
substr("hello", -2, -1)
</code>
</td>
</tr>
<tr>
<td>
format( fmt, ...)
</td>
<td>
Use the arguments following
<code>
fmt
</code>
to format a string.
<br/>
Currently the only format argument supported is
<code>
%s
</code>
and it applies to all types of arguments.
</td>
<td>
<code>
format("Hello, %s, you are %s years old", @name, @age)
</code>
</td>
</tr>
<tr>
<td>
matched_terms([max_terms=100])
</td>
<td>
Return the query terms that matched for each record (up to 100), as a list. If a limit is specified, Redis will return the first N matches found, based on query order.
</td>
<td>
<code>
matched_terms()
</code>
</td>
</tr>
<tr>
<td>
split(s, [sep=","], [strip=" "])
</td>
<td>
Split a string by any character in the string sep, and strip any characters in strip. If only s is specified, it is split by commas and spaces are stripped. The output is an array.
</td>
<td>
split("foo,bar")
</td>
</tr>
</tbody>
</table>
<h3 id="list-of-datetime-apply-functions">
List of date/time APPLY functions
</h3>
<table>
<thead>
<tr>
<th>
Function
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
timefmt(x, [fmt])
</td>
<td>
Return a formatted time string based on a numeric timestamp value x.
<br/>
See
<a href="https://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html">
strftime
</a>
for formatting options.
<br/>
Not specifying
<code>
fmt
</code>
is equivalent to
<code>
%FT%TZ
</code>
.
</td>
</tr>
<tr>
<td>
parsetime(timesharing, [fmt])
</td>
<td>
The opposite of timefmt() - parse a time format using a given format string
</td>
</tr>
<tr>
<td>
day(timestamp)
</td>
<td>
Round a Unix timestamp to midnight (00:00) start of the current day.
</td>
</tr>
<tr>
<td>
hour(timestamp)
</td>
<td>
Round a Unix timestamp to the beginning of the current hour.
</td>
</tr>
<tr>
<td>
minute(timestamp)
</td>
<td>
Round a Unix timestamp to the beginning of the current minute.
</td>
</tr>
<tr>
<td>
month(timestamp)
</td>
<td>
Round a unix timestamp to the beginning of the current month.
</td>
</tr>
<tr>
<td>
dayofweek(timestamp)
</td>
<td>
Convert a Unix timestamp to the day number (Sunday = 0).
</td>
</tr>
<tr>
<td>
dayofmonth(timestamp)
</td>
<td>
Convert a Unix timestamp to the day of month number (1 .. 31).
</td>
</tr>
<tr>
<td>
dayofyear(timestamp)
</td>
<td>
Convert a Unix timestamp to the day of year number (0 .. 365).
</td>
</tr>
<tr>
<td>
year(timestamp)
</td>
<td>
Convert a Unix timestamp to the current year (e.g. 2018).
</td>
</tr>
<tr>
<td>
monthofyear(timestamp)
</td>
<td>
Convert a Unix timestamp to the current month (0 .. 11).
</td>
</tr>
</tbody>
</table>
<h3 id="list-of-geo-apply-functions">
List of geo APPLY functions
</h3>
<table>
<thead>
<tr>
<th>
Function
</th>
<th>
Description
</th>
<th>
Example
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
geodistance(field,field)
</td>
<td>
Return distance in meters.
</td>
<td>
<code>
geodistance(@field1,@field2)
</code>
</td>
</tr>
<tr>
<td>
geodistance(field,"lon,lat")
</td>
<td>
Return distance in meters.
</td>
<td>
<code>
geodistance(@field,"1.2,-3.4")
</code>
</td>
</tr>
<tr>
<td>
geodistance(field,lon,lat)
</td>
<td>
Return distance in meters.
</td>
<td>
<code>
geodistance(@field,1.2,-3.4)
</code>
</td>
</tr>
<tr>
<td>
geodistance("lon,lat",field)
</td>
<td>
Return distance in meters.
</td>
<td>
<code>
geodistance("1.2,-3.4",@field)
</code>
</td>
</tr>
<tr>
<td>
geodistance("lon,lat","lon,lat")
</td>
<td>
Return distance in meters.
</td>
<td>
<code>
geodistance("1.2,-3.4","5.6,-7.8")
</code>
</td>
</tr>
<tr>
<td>
geodistance("lon,lat",lon,lat)
</td>
<td>
Return distance in meters.
</td>
<td>
<code>
geodistance("1.2,-3.4",5.6,-7.8)
</code>
</td>
</tr>
<tr>
<td>
geodistance(lon,lat,field)
</td>
<td>
Return distance in meters.
</td>
<td>
<code>
geodistance(1.2,-3.4,@field)
</code>
</td>
</tr>
<tr>
<td>
geodistance(lon,lat,"lon,lat")
</td>
<td>
Return distance in meters.
</td>
<td>
<code>
geodistance(1.2,-3.4,"5.6,-7.8")
</code>
</td>
</tr>
<tr>
<td>
geodistance(lon,lat,lon,lat)
</td>
<td>
Return distance in meters.
</td>
<td>
<code>
geodistance(1.2,-3.4,5.6,-7.8)
</code>
</td>
</tr>
</tbody>
</table>
<pre tabindex="0"><code>FT.AGGREGATE myIdx "*" LOAD 1 location APPLY "geodistance(@location,\"-1.1,2.2\")" AS dist
</code></pre>
<p>
To retrieve the distance:
</p>
<pre tabindex="0"><code>FT.AGGREGATE myIdx "*" LOAD 1 location APPLY "geodistance(@location,\"-1.1,2.2\")" AS dist
</code></pre>
<p>
Note: the geo field must be preloaded using
<code>
LOAD
</code>
.
</p>
<p>
Results can also be sorted by distance:
</p>
<pre tabindex="0"><code>FT.AGGREGATE idx "*" LOAD 1 @location FILTER "exists(@location)" APPLY "geodistance(@location,-117.824722,33.68590)" AS dist SORTBY 2 @dist DESC
</code></pre>
<p>
Note: Make sure no location is missing, otherwise the SORTBY will not return any results.
Use FILTER to make sure you do the sorting on all valid locations.
</p>
<h2 id="filter-expressions">
FILTER expressions
</h2>
<p>
FILTER expressions filter the results using predicates relating to values in the result set.
</p>
<p>
The FILTER expressions are evaluated post-query and relate to the current state of the pipeline. Thus they can be useful to prune the results based on group calculations. Note that the filters are not indexed and will not speed up processing.
</p>
<p>
Filter expressions follow the syntax of APPLY expressions, with the addition of the conditions
<code>
==
</code>
,
<code>
!=
</code>
,
<code>
<
</code>
,
<code>
<=
</code>
,
<code>
>
</code>
,
<code>
>=
</code>
. Two or more predicates can be combined with logical AND (
<code>
&&
</code>
) and OR (
<code>
||
</code>
). A single predicate can be negated with a NOT prefix (
<code>
!
</code>
).
</p>
<p>
For example, filtering all results where the user name is 'foo' and the age is less than 20 is expressed as:
</p>
<pre tabindex="0"><code>FT.AGGREGATE
...
FILTER "@name=='foo' && @age < 20"
...
</code></pre>
<p>
Several filter steps can be added, although at the same stage in the pipeline, it is more efficient to combine several predicates into a single filter step.
</p>
<h2 id="cursor-api">
Cursor API
</h2>
<pre tabindex="0"><code>FT.AGGREGATE ... WITHCURSOR [COUNT {read size} MAXIDLE {idle timeout}]
FT.CURSOR READ {idx} {cid} [COUNT {read size}]
FT.CURSOR DEL {idx} {cid}
</code></pre>
<p>
You can use cursors with
<a href="/docs/latest/commands/ft.aggregate/">
<code>
FT.AGGREGATE
</code>
</a>
, with the
<code>
WITHCURSOR
</code>
keyword. Cursors allow you to
consume only part of the response, allowing you to fetch additional results as needed.
This is much quicker than using
<code>
LIMIT
</code>
with offset, since the query is executed only
once, and its state is stored on the server.
</p>
<p>
To use cursors, specify the
<code>
WITHCURSOR
</code>
keyword in
<a href="/docs/latest/commands/ft.aggregate/">
<code>
FT.AGGREGATE
</code>
</a>
. For example:
</p>
<pre tabindex="0"><code>FT.AGGREGATE idx * WITHCURSOR
</code></pre>
<p>
This will return a response of an array with two elements. The first element is
the actual (partial) result, and the second is the cursor ID. The cursor ID
can then be fed to
<a href="/docs/latest/commands/ft.cursor-read/">
<code>
FT.CURSOR READ
</code>
</a>
repeatedly until the cursor ID is 0, in
which case all results have been returned.
</p>
<p>
To read from an existing cursor, use
<a href="/docs/latest/commands/ft.cursor-read/">
<code>
FT.CURSOR READ
</code>
</a>
. For example:
</p>
<pre tabindex="0"><code>FT.CURSOR READ idx 342459320
</code></pre>
<p>
Assuming
<code>
342459320
</code>
is the cursor ID returned from the
<a href="/docs/latest/commands/ft.aggregate/">
<code>
FT.AGGREGATE
</code>
</a>
request, here is an example in pseudo-code:
</p>
<pre tabindex="0"><code>response, cursor = FT.AGGREGATE "idx" "redis" "WITHCURSOR";
while (1) {
processResponse(response)
if (!cursor) {
break;
}
response, cursor = FT.CURSOR read "idx" cursor
}
</code></pre>
<p>
Note that even if the cursor is 0, a partial result may still be returned.
</p>
<h3 id="cursor-settings">
Cursor settings
</h3>
<h4 id="read-size">
Read size
</h4>
<p>
You can control how many rows are read for each cursor fetch by using the
<code>
COUNT
</code>
parameter. This parameter can be specified both in
<a href="/docs/latest/commands/ft.aggregate/">
<code>
FT.AGGREGATE
</code>
</a>
(immediately after
<code>
WITHCURSOR
</code>
) or in
<a href="/docs/latest/commands/ft.cursor-read/">
<code>
FT.CURSOR READ
</code>
</a>
.
</p>
<p>
The following example will read 10 rows at a time:
</p>
<pre tabindex="0"><code>FT.AGGREGATE idx query WITHCURSOR COUNT 10
</code></pre>
<p>
You can override this setting by also specifying
<code>
COUNT
</code>
in
<code>
CURSOR READ
</code>
. The following example will return at most 50 results:
</p>
<pre tabindex="0"><code>FT.CURSOR READ idx 342459320 COUNT 50
</code></pre>
<p>
The default read size is 1000.
</p>
<h4 id="timeouts-and-limits">
Timeouts and limits
</h4>
<p>
Because cursors are stateful resources that occupy memory on the server, they
have a limited lifetime. To safeguard against orphaned/stale cursors,
cursors have an idle timeout value. If no activity occurs on the cursor before
the idle timeout, the cursor is deleted. The idle timer resets to 0 whenever
the cursor is read from using
<code>
CURSOR READ
</code>
.
</p>
<p>
The default idle timeout is 300000 milliseconds (or 300 seconds). You can modify
the idle timeout using the
<code>
MAXIDLE
</code>
keyword when creating the cursor. Note that
the value cannot exceed the default 300s.
</p>
<p>
For example, to set a limit of ten seconds:
</p>
<pre tabindex="0"><code>FT.AGGREGATE idx query WITHCURSOR MAXIDLE 10000
</code></pre>
<h3 id="other-cursor-commands">
Other cursor commands
</h3>
<p>
Cursors can be explicitly deleted using the
<code>
CURSOR DEL
</code>
command. For example:
</p>
<pre tabindex="0"><code>FT.CURSOR DEL idx 342459320
</code></pre>
<p>
Note that cursors are automatically deleted if all their results have been
returned, or if they have timed out.
</p>
<p>
All idle cursors can be forcefully purged at the same time using
<code>
FT.CURSOR GC idx 0
</code>
command.
By default, Redis Stack uses a lazy throttled approach to garbage collection, which
collects idle cursors every 500 operations, or every second, whichever is later.
</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/advanced-concepts/aggregations/"/>
<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/watch/.html | <section class="prose w-full py-12">
<h1 class="command-name">
WATCH
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">WATCH key [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.0
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(1) for every key.
</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>
@transaction
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
Marks the given keys to be watched for conditional execution of a
<a href="/develop/interact/transactions">
transaction
</a>
.
</p>
<h2 id="resp2resp3-reply">
RESP2/RESP3 Reply
</h2>
<a href="../../develop/reference/protocol-spec#simple-strings">
Simple string reply
</a>
:
<code>
OK
</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/watch/"/>
<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/v2.28.0/.html | <section class="prose w-full py-12">
<h1>
RedisInsight v2.28.0, June 2023
</h1>
<p class="text-lg -mt-5 mb-10">
RedisInsight v2.28
</p>
<h2 id="228-june-2023">
2.28 (June 2023)
</h2>
<p>
This is the General Availability (GA) release of RedisInsight 2.28.
</p>
<h3 id="highlights">
Highlights
</h3>
<ul>
<li>
Quickly and conveniently add
<a href="https://redis.com/redis-enterprise-cloud/overview/">
Redis Cloud
</a>
databases that belong to fixed subscriptions using the auto-discovery tool
</li>
<li>
UX optimizations in Browser for an improved experience when performing
<a href="https://redis.io/docs/stack/search/">
full-text search and queries
</a>
, filtering, and bulk actions.
</li>
<li>
Support for a monospaced font in
<a href="https://redis.io/docs/stack/json/">
JSON
</a>
key types
</li>
</ul>
<h3 id="details">
Details
</h3>
<p>
<strong>
Features and improvements
</strong>
</p>
<ul>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/2198">
#2198
</a>
,
<a href="https://github.com/RedisInsight/RedisInsight/pull/2207">
#2207
</a>
Automatically discover and add
<a href="https://redis.com/redis-enterprise-cloud/overview/">
Redis Cloud
</a>
databases that belong to fixed subscriptions using the
<code>
Redis Cloud
</code>
option on the form to auto-discover databases.
</li>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/2146">
#2146
</a>
,
<a href="https://github.com/RedisInsight/RedisInsight/pull/2161">
#2161
</a>
Added UX optimizations in the Browser layout to improve the experience when performing
<a href="https://redis.io/docs/stack/search/">
full-text search and queries
</a>
, filtering, and bulk actions.
</li>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/2200">
#2200
</a>
Changed to a monospaced font in
<a href="https://redis.io/docs/stack/json/">
JSON
</a>
key types, and JSON formatters in Browser and Workbench.
</li>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/2204">
#2204
</a>
Re-bind default RedisInsight port from 5001 to 5530 to avoid conflicts with other applications
</li>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/2120">
#2120
</a>
Added the ability to investigate the commands processed by Redis or Redis Stack server without the need to stop Profiler when a new record appears.
</li>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/2186">
#2186
</a>
Unified the RedisInsight icon with other macOS applications.
</li>
</ul>
<p>
<strong>
Bugs
</strong>
</p>
<ul>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/2154">
#2154
</a>
Display
<code>
(integer) 0
</code>
instead of
<code>
nil
</code>
in
<a href="https://redis.io/commands/zrank/">
ZRANK
</a>
results in Workbench
</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/v2.28.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/rs/installing-upgrading/install/install-script/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Installation script command-line options
</h1>
<p class="text-lg -mt-5 mb-10">
Command-line options for the install.sh script.
</p>
<p>
Run
<code>
./install.sh --help
</code>
to view command-line options supported by the installation script.
</p>
<p>
The following options are supported:
</p>
<table>
<thead>
<tr>
<th>
Option
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>
-y
</code>
</td>
<td>
Automatically answers
<code>
yes
</code>
to all install prompts, accepting all default values
<br/>
See
<a href="/docs/latest/operate/rs/installing-upgrading/install/manage-installation-questions/">
Manage install questions
</a>
</td>
</tr>
<tr>
<td>
<nobr>
<code>
-c <answer file>
</code>
</nobr>
</td>
<td>
Specify answer file used to respond to install prompts
<br/>
See
<a href="/docs/latest/operate/rs/installing-upgrading/install/manage-installation-questions/">
Manage install questions
</a>
</td>
</tr>
<tr>
<td>
<nobr>
<code>
-s <socket dir>
</code>
</nobr>
</td>
<td>
Specify directory for redislabs unix sockets
<em>
(new installs only)
</em>
</td>
</tr>
<tr>
<td>
<nobr>
<code>
--install-dir <dir>
</code>
</nobr>
</td>
<td>
Specifies installation directory
<em>
(new installs only)
</em>
<br/>
See
<a href="/docs/latest/operate/rs/installing-upgrading/install/customize-install-directories/">
Customize install locations
</a>
</td>
</tr>
<tr>
<td>
<nobr>
<code>
--config-dir <dir>
</code>
</nobr>
</td>
<td>
Configuration file directory
<em>
(new installs only)
</em>
<br/>
See
<a href="/docs/latest/operate/rs/installing-upgrading/install/customize-install-directories/">
Customize install locations
</a>
</td>
</tr>
<tr>
<td>
<nobr>
<code>
--var-dir <dir>
</code>
</nobr>
</td>
<td>
Var directory used for installation
<em>
(new installs only)
</em>
<br/>
See
<a href="/docs/latest/operate/rs/installing-upgrading/install/customize-install-directories/">
Customize install locations
</a>
</td>
</tr>
<tr>
<td>
<nobr>
<code>
--os-user <user>
</code>
</nobr>
</td>
<td>
Operating system user account associated with install; default:
<code>
redislabs
</code>
<br/>
See
<a href="/docs/latest/operate/rs/installing-upgrading/install/customize-user-and-group/">
Customize user and group
</a>
<em>
(new installs only)
</em>
</td>
</tr>
<tr>
<td>
<nobr>
<code>
--os-group <group>
</code>
</nobr>
</td>
<td>
Operating system group associated with install; default:
<code>
redislabs
</code>
<br/>
See
<a href="/docs/latest/operate/rs/installing-upgrading/install/customize-user-and-group/">
Customize user and group
</a>
<em>
(new installs only)
</em>
</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/installing-upgrading/install/install-script/"/>
<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/management/optimization/latency-monitor.html | <section class="prose w-full py-12 max-w-none">
<h1>
Redis latency monitoring
</h1>
<p class="text-lg -mt-5 mb-10">
Discovering slow server events in Redis
</p>
<p>
Redis is often used for demanding use cases, where it
serves a large number of queries per second per instance, but also has strict latency requirements for the average response
time and the worst-case latency.
</p>
<p>
While Redis is an in-memory system, it deals with the operating system in
different ways, for example, in the context of persisting to disk.
Moreover Redis implements a rich set of commands. Certain commands
are fast and run in constant or logarithmic time. Other commands are slower
O(N) commands that can cause latency spikes.
</p>
<p>
Finally, Redis is single threaded. This is usually an advantage
from the point of view of the amount of work it can perform per core, and in
the latency figures it is able to provide. However, it poses
a challenge for latency, since the single
thread must be able to perform certain tasks incrementally, for
example key expiration, in a way that does not impact the other clients
that are served.
</p>
<p>
For all these reasons, Redis 2.8.13 introduced a new feature called
<strong>
Latency Monitoring
</strong>
, that helps the user to check and troubleshoot possible
latency problems. Latency monitoring is composed of the following conceptual
parts:
</p>
<ul>
<li>
Latency hooks that sample different latency-sensitive code paths.
</li>
<li>
Time series recording of latency spikes, split by different events.
</li>
<li>
Reporting engine to fetch raw data from the time series.
</li>
<li>
Analysis engine to provide human-readable reports and hints according to the measurements.
</li>
</ul>
<p>
The rest of this document covers the latency monitoring subsystem
details. For more information about the general topic of Redis
and latency, see
<a href="/docs/latest/operate/oss_and_stack/management/optimization/latency/">
Redis latency problems troubleshooting
</a>
.
</p>
<h2 id="events-and-time-series">
Events and time series
</h2>
<p>
Different monitored code paths have different names and are called
<em>
events
</em>
.
For example,
<code>
command
</code>
is an event that measures latency spikes of possibly slow
command executions, while
<code>
fast-command
</code>
is the event name for the monitoring
of the O(1) and O(log N) commands. Other events are less generic and monitor
specific operations performed by Redis. For example, the
<code>
fork
</code>
event
only monitors the time taken by Redis to execute the
<code>
fork(2)
</code>
system call.
</p>
<p>
A latency spike is an event that takes more time to run than the configured latency
threshold. There is a separate time series associated with every monitored
event. This is how the time series work:
</p>
<ul>
<li>
Every time a latency spike happens, it is logged in the appropriate time series.
</li>
<li>
Every time series is composed of 160 elements.
</li>
<li>
Each element is a pair made of a Unix timestamp of the time the latency spike was measured and the number of milliseconds the event took to execute.
</li>
<li>
Latency spikes for the same event that occur in the same second are merged by taking the maximum latency. Even if continuous latency spikes are measured for a given event, which could happen with a low threshold, at least 160 seconds of history are available.
</li>
<li>
Records the all-time maximum latency for every element.
</li>
</ul>
<p>
The framework monitors and logs latency spikes in the execution time of these events:
</p>
<ul>
<li>
<code>
command
</code>
: regular commands.
</li>
<li>
<code>
fast-command
</code>
: O(1) and O(log N) commands.
</li>
<li>
<code>
fork
</code>
: the
<code>
fork(2)
</code>
system call.
</li>
<li>
<code>
rdb-unlink-temp-file
</code>
: the
<code>
unlink(2)
</code>
system call.
</li>
<li>
<code>
aof-fsync-always
</code>
: the
<code>
fsync(2)
</code>
system call when invoked by the
<code>
appendfsync allways
</code>
policy.
</li>
<li>
<code>
aof-write
</code>
: writing to the AOF - a catchall event for
<code>
write(2)
</code>
system calls.
</li>
<li>
<code>
aof-write-pending-fsync
</code>
: the
<code>
write(2)
</code>
system call when there is a pending fsync.
</li>
<li>
<code>
aof-write-active-child
</code>
: the
<code>
write(2)
</code>
system call when there are active child processes.
</li>
<li>
<code>
aof-write-alone
</code>
: the
<code>
write(2)
</code>
system call when no pending fsync and no active child process.
</li>
<li>
<code>
aof-fstat
</code>
: the
<code>
fstat(2)
</code>
system call.
</li>
<li>
<code>
aof-rename
</code>
: the
<code>
rename(2)
</code>
system call for renaming the temporary file after completing
<a href="/commands/bgrewriteaof">
<code>
BGREWRITEAOF
</code>
</a>
.
</li>
<li>
<code>
aof-rewrite-diff-write
</code>
: writing the differences accumulated while performing
<a href="/commands/bgrewriteaof">
<code>
BGREWRITEAOF
</code>
</a>
.
</li>
<li>
<code>
active-defrag-cycle
</code>
: the active defragmentation cycle.
</li>
<li>
<code>
expire-cycle
</code>
: the expiration cycle.
</li>
<li>
<code>
eviction-cycle
</code>
: the eviction cycle.
</li>
<li>
<code>
eviction-del
</code>
: deletes during the eviction cycle.
</li>
</ul>
<h2 id="how-to-enable-latency-monitoring">
How to enable latency monitoring
</h2>
<p>
What is high latency for one use case may not be considered high latency for another. Some applications may require that all queries be served in less than 1 millisecond. For other applications, it may be acceptable for a small amount of clients to experience a 2 second latency on occasion.
</p>
<p>
The first step to enable the latency monitor is to set a
<strong>
latency threshold
</strong>
in milliseconds. Only events that take longer than the specified threshold will be logged as latency spikes. The user should set the threshold according to their needs. For example, if the application requires a maximum acceptable latency of 100 milliseconds, the threshold should be set to log all the events blocking the server for a time equal or greater to 100 milliseconds.
</p>
<p>
Enable the latency monitor at runtime in a production server
with the following command:
</p>
<pre><code>CONFIG SET latency-monitor-threshold 100
</code></pre>
<p>
Monitoring is turned off by default (threshold set to 0), even if the actual cost of latency monitoring is near zero. While the memory requirements of latency monitoring are very small, there is no good reason to raise the baseline memory usage of a Redis instance that is working well.
</p>
<h2 id="report-information-with-the-latency-command">
Report information with the LATENCY command
</h2>
<p>
The user interface to the latency monitoring subsystem is the
<a href="/commands/latency">
<code>
LATENCY
</code>
</a>
command.
Like many other Redis commands,
<a href="/commands/latency">
<code>
LATENCY
</code>
</a>
accepts subcommands that modify its behavior. These subcommands are:
</p>
<ul>
<li>
<a href="/commands/latency-latest">
<code>
LATENCY LATEST
</code>
</a>
- returns the latest latency samples for all events.
</li>
<li>
<a href="/commands/latency-history">
<code>
LATENCY HISTORY
</code>
</a>
- returns latency time series for a given event.
</li>
<li>
<a href="/commands/latency-reset">
<code>
LATENCY RESET
</code>
</a>
- resets latency time series data for one or more events.
</li>
<li>
<a href="/commands/latency-graph">
<code>
LATENCY GRAPH
</code>
</a>
- renders an ASCII-art graph of an event's latency samples.
</li>
<li>
<a href="/commands/latency-doctor">
<code>
LATENCY DOCTOR
</code>
</a>
- replies with a human-readable latency analysis report.
</li>
</ul>
<p>
Refer to each subcommand's documentation page for further information.
</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/oss_and_stack/management/optimization/latency-monitor/"/>
<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/client_references/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Develop with Redis clients
</h1>
<p class="text-lg -mt-5 mb-10">
Redis client libraries allow you to connect to Redis instances from within your application. This section provides an overview of several recommended Redis clients for popular programming and scripting languages.
</p>
<p>
To connect to Redis instances from within your application, use a Redis client library that matches your application's language.
</p>
<h2 id="official-clients">
Official clients
</h2>
<table>
<thead>
<tr>
<th style="text-align:left">
Language
</th>
<th style="text-align:left">
Client name
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
.Net
</td>
<td style="text-align:left">
<a href="/docs/latest/develop/clients/dotnet/">
NRedisStack
</a>
</td>
</tr>
<tr>
<td style="text-align:left">
Go
</td>
<td style="text-align:left">
<a href="/docs/latest/develop/clients/go/">
go-redis
</a>
</td>
</tr>
<tr>
<td style="text-align:left">
Java
</td>
<td style="text-align:left">
<a href="/docs/latest/develop/clients/jedis/">
Jedis
</a>
(Synchronous) and
<a href="/docs/latest/develop/clients/lettuce/">
Lettuce
</a>
(Asynchronous)
</td>
</tr>
<tr>
<td style="text-align:left">
Node.js
</td>
<td style="text-align:left">
<a href="/docs/latest/develop/clients/nodejs/">
node-redis
</a>
</td>
</tr>
<tr>
<td style="text-align:left">
Python
</td>
<td style="text-align:left">
<a href="/docs/latest/develop/clients/redis-py/">
redis-py
</a>
</td>
</tr>
</tbody>
</table>
<p>
Select a client name to see its quick start.
</p>
<h2 id="other-clients">
Other clients
</h2>
<p>
For a list of community-driven Redis clients, which are available for more programming languages, see
<a href="/docs/latest/develop/clients/#community-supported-clients">
Community-supported clients
</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/references/client_references/"/>
<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/client-setname/.html | <section class="prose w-full py-12">
<h1 class="command-name">
CLIENT SETNAME
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">CLIENT SETNAME connection-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">
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 SETNAME
</code>
command assigns a name to the current connection.
</p>
<p>
The assigned name is displayed in the output of
<a href="/docs/latest/commands/client-list/">
<code>
CLIENT LIST
</code>
</a>
so that it is possible to identify the client that performed a given connection.
</p>
<p>
For instance when Redis is used in order to implement a queue, producers and consumers of messages may want to set the name of the connection according to their role.
</p>
<p>
There is no limit to the length of the name that can be assigned if not the usual limits of the Redis string type (512 MB). However it is not possible to use spaces in the connection name as this would violate the format of the
<a href="/docs/latest/commands/client-list/">
<code>
CLIENT LIST
</code>
</a>
reply.
</p>
<p>
It is possible to entirely remove the connection name setting it to the empty string, that is not a valid connection name since it serves to this specific purpose.
</p>
<p>
The connection name can be inspected using
<a href="/docs/latest/commands/client-getname/">
<code>
CLIENT GETNAME
</code>
</a>
.
</p>
<p>
Every new connection starts without an assigned name.
</p>
<p>
Tip: setting names to connections is a good way to debug connection leaks due to bugs in the application using Redis.
</p>
<h2 id="resp2resp3-reply">
RESP2/RESP3 Reply
</h2>
<a href="../../develop/reference/protocol-spec#simple-strings">
Simple string reply
</a>
:
<code>
OK
</code>
if the connection name was successfully 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/client-setname/"/>
<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/script-exists/.html | <section class="prose w-full py-12">
<h1 class="command-name">
SCRIPT EXISTS
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">SCRIPT EXISTS sha1 [sha1 ...]</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.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 scripts to check (so checking a single script is an O(1) operation).
</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>
@scripting
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
Returns information about the existence of the scripts in the script cache.
</p>
<p>
This command accepts one or more SHA1 digests and returns a list of ones or
zeros to signal if the scripts are already defined or not inside the script
cache.
This can be useful before a pipelining operation to ensure that scripts are
loaded (and if not, to load them using
<a href="/docs/latest/commands/script-load/">
<code>
SCRIPT LOAD
</code>
</a>
) so that the pipelining
operation can be performed solely using
<a href="/docs/latest/commands/evalsha/">
<code>
EVALSHA
</code>
</a>
instead of
<a href="/docs/latest/commands/eval/">
<code>
EVAL
</code>
</a>
to save
bandwidth.
</p>
<p>
For more information about
<a href="/docs/latest/commands/eval/">
<code>
EVAL
</code>
</a>
scripts please refer to
<a href="/docs/latest/develop/interact/programmability/eval-intro/">
Introduction to Eval Scripts
</a>
.
</p>
<h2 id="resp2resp3-reply">
RESP2/RESP3 Reply
</h2>
<a href="../../develop/reference/protocol-spec#arrays">
Array reply
</a>
: an array of integers that correspond to the specified SHA1 digest arguments.
<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/script-exists/"/>
<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/certificate/.html | <section class="prose w-full py-12 max-w-none">
<h1>
rladmin cluster certificate
</h1>
<p class="text-lg -mt-5 mb-10">
Sets the cluster certificate.
</p>
<p>
Sets a cluster certificate to a specified PEM file.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin cluster certificate
</span></span><span class="line"><span class="cl"> <span class="nb">set</span> <certificate name>
</span></span><span class="line"><span class="cl"> certificate_file <certificate filepath>
</span></span><span class="line"><span class="cl"> <span class="o">[</span> key_file <key filepath> <span class="o">]</span>
</span></span></code></pre>
</div>
<p>
To set a certificate for a specific service, use the corresponding certificate name. See the
<a href="/docs/latest/operate/rs/security/certificates/">
certificates table
</a>
for the list of cluster certificates and their descriptions.
</p>
<h3 id="parameters">
Parameters
</h3>
<table>
<thead>
<tr>
<th>
Parameter
</th>
<th>
Type/Value
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
certificate name
</td>
<td>
'cm'
<br/>
'api'
<br/>
'proxy'
<br/>
'syncer'
<br/>
'metrics_exporter'
</td>
<td>
Name of the certificate to update
</td>
</tr>
<tr>
<td>
certificate_file
</td>
<td>
filepath
</td>
<td>
Path to the certificate file
</td>
</tr>
<tr>
<td>
key_file
</td>
<td>
filepath
</td>
<td>
Path to the key file (optional)
</td>
</tr>
</tbody>
</table>
<h3 id="returns">
Returns
</h3>
<p>
Reports that the certificate was set to the specified file. Returns an error message if the certificate fails to update.
</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 certificate <span class="nb">set</span> proxy <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span> certificate_file /tmp/proxy.pem
</span></span><span class="line"><span class="cl">Set proxy certificate to contents of file /tmp/proxy.pem
</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/certificate/"/>
<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-start/.html | <section class="prose w-full py-12 max-w-none">
<h1>
redis-di start
</h1>
<p class="text-lg -mt-5 mb-10">
Starts the pipeline
</p>
<h2 id="usage">
Usage
</h2>
<pre tabindex="0"><code>Usage: redis-di start [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: <IntRange 1000<=x<=65535>
</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 start [OPTIONS]
Starts 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<=x<=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-start/"/>
<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/bloom/release-notes/redisbloom-2.4-release-notes/.html | <section class="prose w-full py-12 max-w-none">
<h1>
RedisBloom 2.4 release notes
</h1>
<p class="text-lg -mt-5 mb-10">
Added t-digest - a probabilistic data structure for estimating quantiles based on a data stream or a large dataset of floating-point values.
</p>
<h2 id="requirements">
Requirements
</h2>
<p>
RedisBloom v2.4.9 requires:
</p>
<ul>
<li>
Minimum Redis compatibility version (database): 6.0.16
</li>
<li>
Minimum Redis Enterprise Software version (cluster): 6.2.8
</li>
</ul>
<h2 id="v249-march-2024">
v2.4.9 (March 2024)
</h2>
<p>
This is a maintenance release for RedisBloom 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/RedisBloom/RedisBloom/issues/753">
#753
</a>
Potential crash on
<code>
CMS.MERGE
</code>
when using invalid arguments
</li>
</ul>
</li>
</ul>
<h2 id="v248-january-2024">
v2.4.8 (January 2024)
</h2>
<p>
This is a maintenance release for RedisBloom 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/RedisBloom/RedisBloom/pull/727">
#727
</a>
Additional fixes for potential crash on
<code>
CF.LOADCHUNK
</code>
(MOD-6344)
</li>
</ul>
</li>
</ul>
<h2 id="v247-january-2024">
v2.4.7 (January 2024)
</h2>
<p>
This is a maintenance release for RedisBloom 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/RedisBloom/RedisBloom/pull/735">
#735
</a>
Potential crash on
<code>
CF.RESERVE
</code>
(MOD-6343)
</li>
<li>
<a href="https://github.com/RedisBloom/RedisBloom/pull/727">
#727
</a>
Potential crash on
<code>
CF.LOADCHUNK
</code>
(MOD-6344)
</li>
</ul>
</li>
</ul>
<h2 id="v246-december-2023">
v2.4.6 (December 2023)
</h2>
<p>
This is a maintenance release for RedisBloom 2.4.
</p>
<p>
Update urgency:
<code>
LOW
</code>
: No need to upgrade unless there are new features you want to use.
</p>
<p>
Details:
</p>
<ul>
<li>
<p>
Bug fixes:
</p>
<ul>
<li>
<a href="https://github.com/RedisBloom/RedisBloom/pull/707">
#707
</a>
Top-K:
<code>
TOPK.ADD
</code>
and
<code>
TOPK.QUERY
</code>
crash when an item name is an empty string (RED-114676)
</li>
</ul>
</li>
<li>
<p>
Improvements:
</p>
<ul>
<li>
<a href="https://github.com/RedisBloom/RedisBloom/pull/706">
#706
</a>
Added support for CBL-Mariner 2 (MOD-6200)
</li>
</ul>
</li>
</ul>
<h2 id="v245-april-2023">
v2.4.5 (April 2023)
</h2>
<p>
This is a maintenance release for RedisBloom 2.4.
</p>
<p>
Update urgency:
<code>
LOW
</code>
: No need to upgrade unless there are new features you want to use.
</p>
<p>
Details:
</p>
<ul>
<li>
<p>
Improvements:
</p>
<ul>
<li>
Internal changes for supporting future Redis Enterprise releases
</li>
</ul>
</li>
</ul>
<h2 id="v244-february-2023">
v2.4.4 (February 2023)
</h2>
<p>
This is a maintenance release for RedisBloom 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/RedisBloom/RedisBloom/issues/609">
#609
</a>
<a href="/docs/latest/commands/cf.info">
CF.INFO
</a>
- incorrect information for large filters
</li>
</ul>
</li>
<li>
<p>
Improvements:
</p>
<ul>
<li>
<a href="https://github.com/RedisBloom/RedisBloom/issues/389">
#389
</a>
Introduce
<a href="/docs/latest/commands/bf.card">
BF.CARD
</a>
to retrieve the cardinality of a Bloom filter or 0 when such key does not exist
</li>
</ul>
</li>
</ul>
<h2 id="v24-ga-v243-november-2022">
v2.4 GA (v2.4.3) (November 2022)
</h2>
<p>
This is the General Availability release of RedisBloom 2.4.
</p>
<h3 id="highlights">
Highlights
</h3>
<p>
RedisBloom 2.4 introduces a new sketch data structure:
<strong>
t-digest
</strong>
.
</p>
<h3 id="whats-new-in-24">
What's new in 2.4
</h3>
<p>
<a href="https://www.sciencedirect.com/science/article/pii/S2665963820300403">
t-digest
</a>
is a probabilistic data structure for estimating quantiles based on a data stream or a large dataset of floating-point values. It can be used to answer the following questions:
</p>
<ul>
<li>
What 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>
Which value is smaller than
<em>
p
</em>
percent of the values in the data stream? (what is the
<em>
p
</em>
-percentile value)?
</li>
<li>
What is the mean value between the
<em>
p1
</em>
-percentile value and the
<em>
p2
</em>
-percentile value?
</li>
<li>
What is the value of the
<em>
n
</em>
-th smallest / largest value in the data stream? (what is the value with [reverse] rank
<em>
n
</em>
)?
</li>
</ul>
<p>
As for any other probabilistic data structures, t-digest requires sublinear space and has controllable space-accuracy tradeoffs.
</p>
<p>
Using t-digest is simple and straightforward:
</p>
<ul>
<li>
<p>
<strong>
Creating a sketch and adding observations
</strong>
</p>
<p>
<code>
TDIGEST.CREATE key [COMPRESSION compression]
</code>
initializes a new t-digest sketch (and errors if the key already exists). The
<code>
COMPRESSION
</code>
argument is used to specify the tradeoff between accuracy and memory consumption. The default is 100. Higher values mean more accuracy.
</p>
<p>
<code>
TDIGEST.ADD key value...
</code>
adds new observations (floating-point values) to the sketch. You can repeat calling
<a href="/docs/latest/commands/tdigest.add">
TDIGEST.ADD
</a>
whenever new observations are available.
</p>
</li>
<li>
<p>
<strong>
Estimating fractions or ranks by values
</strong>
</p>
<p>
Use
<code>
TDIGEST.CDF key value...
</code>
to retrieve, for each input
<strong>
value
</strong>
, an estimation of the
<strong>
fraction
</strong>
of (observations
<strong>
smaller
</strong>
than the given value + half the observations equal to the given value).
</p>
<p>
<code>
TDIGEST.RANK key value...
</code>
is similar to
<a href="/docs/latest/commands/tdigest.cdf">
TDIGEST.CDF
</a>
, but used for estimating the number of observations instead of the fraction of observations. More accurately it returns, for each input
<strong>
value
</strong>
, an estimation of the
<strong>
number
</strong>
of (observations
<strong>
smaller
</strong>
than a given value + half the observations equal to the given value).
</p>
<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
<strong>
value
</strong>
, an estimation of the
<strong>
number
</strong>
of (observations
<strong>
larger
</strong>
than a given value + half the observations equal to the given value).
</p>
</li>
<li>
<p>
<strong>
Estimating values by fractions or ranks
</strong>
</p>
<p>
<code>
TDIGEST.QUANTILE key fraction...
</code>
returns, for each input
<strong>
fraction
</strong>
, an estimation of the
<strong>
value
</strong>
(floating point) that is
<strong>
smaller
</strong>
than the given fraction of observations.
</p>
<p>
<code>
TDIGEST.BYRANK key rank...
</code>
returns, for each input
<strong>
rank
</strong>
, an estimation of the
<strong>
value
</strong>
(floating point) with that rank.
</p>
<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>
</li>
<li>
<p>
<strong>
Estimating trimmed mean
</strong>
</p>
<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>
</li>
<li>
<p>
<strong>
Merging sketches
</strong>
</p>
<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>
</li>
<li>
<p>
<strong>
Retrieving sketch information
</strong>
</p>
<p>
Use
<code>
TDIGEST.MIN
</code>
key and
<code>
TDIGEST.MAX key
</code>
to retrieve the minimal and maximal values in the sketch, respectively.
</p>
<p>
Both return NaN (Not a Number) when the sketch is empty.
</p>
<p>
Both commands return accurate results and are equivalent to
<code>
TDIGEST.BYRANK key 0
</code>
and
<code>
TDIGEST.BYREVRANK key 0
</code>
respectively.
</p>
<p>
Use
<code>
TDIGEST.INFO key
</code>
to retrieve some additional information about the sketch.
</p>
</li>
<li>
<p>
<strong>
Resetting a sketch
</strong>
</p>
<p>
<code>
TDIGEST.RESET key
</code>
empties the sketch and reinitializes it.
</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/oss_and_stack/stack-with-enterprise/release-notes/redisbloom/redisbloom-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/operate/rs/references/rest-api/requests/jsonschema/.html | <section class="prose w-full py-12 max-w-none">
<h1>
JSON schema requests
</h1>
<p class="text-lg -mt-5 mb-10">
API object JSON schema requests
</p>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="#get-jsonschema">
GET
</a>
</td>
<td>
<code>
/v1/jsonschema
</code>
</td>
<td>
Get JSON schema of API objects
</td>
</tr>
</tbody>
</table>
<h2 id="get-jsonschema">
Get object JSON schema
</h2>
<pre><code>GET /v1/jsonschema
</code></pre>
<p>
Get the JSON schema of various
<a href="/docs/latest/operate/rs/references/rest-api/objects/">
Redis Enterprise REST API objects
</a>
.
</p>
<h3 id="get-request">
Request
</h3>
<h4 id="example-http-request">
Example HTTP request
</h4>
<pre><code>GET /jsonschema?object=bdb
</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>
<h4 id="query-parameters">
Query parameters
</h4>
<table>
<thead>
<tr>
<th>
Field
</th>
<th>
Type
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
object
</td>
<td>
string
</td>
<td>
Optional. The API object name: 'cluster', 'node', 'bdb' etc.
</td>
</tr>
</tbody>
</table>
<h3 id="get-response">
Response
</h3>
<p>
Returns the JSON schema of the specified API object.
</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="nt">"type"</span><span class="p">:</span> <span class="s2">"object"</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">"An API object that represents a managed database in the cluster."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"properties"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"...."</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"...."</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>
Success.
</td>
</tr>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.7">
406 Not Acceptable
</a>
</td>
<td>
Invalid object.
</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/jsonschema/"/>
<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/docker/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Run Redis Stack on Docker
</h1>
<p class="text-lg -mt-5 mb-10">
How to install Redis Stack using Docker
</p>
<p>
To get started with Redis Stack using Docker, you first need to select a Docker image:
</p>
<ul>
<li>
<p>
<code>
redis/redis-stack
</code>
contains both Redis Stack server and Redis Insight. This container is best for local development because you can use the embedded Redis Insight to visualize your data.
</p>
</li>
<li>
<p>
<code>
redis/redis-stack-server
</code>
provides Redis Stack server only. This container is best for production deployment.
</p>
</li>
</ul>
<h2 id="getting-started">
Getting started
</h2>
<h3 id="redisredis-stack-server">
redis/redis-stack-server
</h3>
<p>
To start Redis Stack server using the
<code>
redis-stack-server
</code>
image, run the following command in your terminal:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">docker run -d --name redis-stack-server -p 6379:6379 redis/redis-stack-server:latest</span></span></code></pre>
</div>
<h3 id="redisredis-stack">
redis/redis-stack
</h3>
<p>
To start a Redis Stack container using the
<code>
redis-stack
</code>
image, run the following command in your terminal:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">docker run -d --name redis-stack -p 6379:6379 -p 8001:8001 redis/redis-stack:latest</span></span></code></pre>
</div>
<p>
The
<code>
docker run
</code>
command above also exposes Redis Insight on port 8001. You can use Redis Insight by pointing your browser to
<code>
localhost:8001
</code>
.
</p>
<h2 id="connect-with-redis-cli">
Connect with redis-cli
</h2>
<p>
You can then connect to the server using
<code>
redis-cli
</code>
, just as you connect to any Redis instance.
</p>
<p>
If you donβt have
<code>
redis-cli
</code>
installed locally, you can run it from the Docker container:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">$ docker <span class="nb">exec</span> -it redis-stack redis-cli</span></span></code></pre>
</div>
<h2 id="configuration">
Configuration
</h2>
<h3 id="persistence-in-docker">
Persistence in Docker
</h3>
<p>
To mount directories or files to your Docker container, specify
<code>
-v
</code>
to configure a local volume. This command stores all data in the local directory
<code>
local-data
</code>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">$ docker run -v /local-data/:/data redis/redis-stack:latest</span></span></code></pre>
</div>
<p>
</p>
<h3 id="ports">
Ports
</h3>
<p>
If you want to expose Redis Stack server or Redis Insight on a different port, update the left hand of portion of the
<code>
-p
</code>
argument. This command exposes Redis Stack server on port
<code>
10001
</code>
and Redis Insight on port
<code>
13333
</code>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">$ docker run -p 10001:6379 -p 13333:8001 redis/redis-stack:latest</span></span></code></pre>
</div>
<p>
</p>
<h3 id="config-files">
Config files
</h3>
<p>
By default, the Redis Stack Docker containers use internal configuration files for Redis. To start Redis with local configuration file, you can use the
<code>
-v
</code>
volume options:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">$ docker run -v <span class="sb">`</span><span class="nb">pwd</span><span class="sb">`</span>/local-redis-stack.conf:/redis-stack.conf -p 6379:6379 -p 8001:8001 redis/redis-stack:latest</span></span></code></pre>
</div>
<h3 id="environment-variables">
Environment variables
</h3>
<p>
To pass in arbitrary configuration changes, you can set any of these environment variables:
</p>
<ul>
<li>
<p>
<code>
REDIS_ARGS
</code>
: extra arguments for Redis
</p>
</li>
<li>
<p>
<code>
REDISEARCH_ARGS
</code>
: arguments for the search and query features (RediSearch)
</p>
</li>
<li>
<p>
<code>
REDISJSON_ARGS
</code>
: arguments for JSON (RedisJSON)
</p>
</li>
<li>
<p>
<code>
REDISTIMESERIES_ARGS
</code>
: arguments for time series (RedisTimeSeries)
</p>
</li>
<li>
<p>
<code>
REDISBLOOM_ARGS
</code>
: arguments for the probabilistic data structures (RedisBloom)
</p>
</li>
</ul>
<p>
For example, here's how to use the
<code>
REDIS_ARGS
</code>
environment variable to pass the
<code>
requirepass
</code>
directive to Redis:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">docker run -e <span class="nv">REDIS_ARGS</span><span class="o">=</span><span class="s2">"--requirepass redis-stack"</span> redis/redis-stack:latest</span></span></code></pre>
</div>
<p>
An example of setting
<a href="/docs/latest/operate/oss_and_stack/management/persistence/">
Redis persistence
</a>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">docker run -e <span class="nv">REDIS_ARGS</span><span class="o">=</span><span class="s2">"--save 60 1000 --appendonly yes"</span> redis/redis-stack:latest</span></span></code></pre>
</div>
<p>
</p>
<p>
Here's how to set a retention policy for time series:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">docker run -e <span class="nv">REDISTIMESERIES_ARGS</span><span class="o">=</span><span class="s2">"RETENTION_POLICY=20"</span> redis/redis-stack:latest</span></span></code></pre>
</div>
<p>
</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/oss_and_stack/install/install-stack/docker/"/>
<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.32.0/.html | <section class="prose w-full py-12">
<h1>
RedisInsight v2.32.0, August 2023
</h1>
<p class="text-lg -mt-5 mb-10">
RedisInsight v2.32
</p>
<h2 id="232-august-2023">
2.32 (August 2023)
</h2>
<p>
This is the General Availability (GA) release of RedisInsight 2.32.
</p>
<h3 id="highlights">
Highlights
</h3>
<ul>
<li>
Easily provision a free database to use with the RedisInsight interactive tutorials to learn, among others, how to leverage Vector Similarity Search for your AI use cases or discover the power of the native JSON data structure supporting structured querying and full-text search. Take advantage of the in-app social sign-up to
<a href="https://redis.com/comparisons/oss-vs-enterprise/?utm_source=redisinsight&utm_medium=rel_notes&utm_campaign=2_32">
Redis Cloud
</a>
to quickly provision a free database with
<a href="https://redis.io/docs/about/about-stack/?utm_source=redisinsight&utm_medium=rel_notes&utm_campaign=2_32">
Redis Stackβs capabilities
</a>
. Try the
<a href="https://redis.com/blog/introducing-redis-7-2/?utm_source=redisinsight&utm_medium=rel_notes&utm_campaign=2_32">
latest 7.2
</a>
release which delivers the new
<a href="https://redis.com/blog/introducing-triggers-and-functions/?utm_source=redisinsight&utm_medium=rel_notes&utm_campaign=2_32">
Triggers and Functions
</a>
feature, allowing you to execute server-side functions written in JavaScript that are either triggered by a keyspace change, by a stream entry arrival, or by explicitly calling them, empowering developers to build and maintain real-time applications by moving business logic closer to the data, ensuring a lower latency whilst delivering the best developer experience.
</li>
<li>
Select a custom installation directory on Windows OS for when multi-user access to the app is required.
</li>
</ul>
<h3 id="details">
Details
</h3>
<p>
<strong>
Features and improvements
</strong>
</p>
<ul>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/2270">
#2270
</a>
,
<a href="https://github.com/RedisInsight/RedisInsight/pull/2271">
#2271
</a>
,
<a href="https://github.com/RedisInsight/RedisInsight/pull/2437">
#2437
</a>
Added the ability to quickly provision a free
<a href="https://redis.com/comparisons/oss-vs-enterprise/?utm_source=redisinsight&utm_medium=rel_notes&utm_campaign=2_32">
Redis Cloud
</a>
database via in-app social signup (Google or GitHub). Use the database with the RedisInsight interactive tutorials or try the
<a href="https://redis.com/blog/introducing-redis-7-2/?utm_source=redisinsight&utm_medium=rel_notes&utm_campaign=2_32">
latest 7.2
</a>
release which delivers the new
<a href="https://redis.com/blog/introducing-triggers-and-functions/?utm_source=redisinsight&utm_medium=rel_notes&utm_campaign=2_32">
Triggers and Functions
</a>
feature. To quickly create and automatically add a free Redis Cloud database to RedisInsight, click the "Try Redis Cloud" banner in the list of database connections page and follow the steps.
</li>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/2455">
#2455
</a>
Select a custom installation directory on Windows OS
</li>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/2373">
#2373
</a>
,
<a href="https://github.com/RedisInsight/RedisInsight/pull/2387">
#2387
</a>
Delete all command results in Workbench at once
</li>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/2458">
#2458
</a>
Added in-app hints in Browser and Workbench to get started with RedisInsight interactive tutorials
</li>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/2422">
#2422
</a>
Ignore the empty lines in files when uploading data in bulk
</li>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/2470">
#2470
</a>
Preset the header containing the engine, the API version and the library name in the JavaScript file when creating a new library within the
<a href="https://redis.com/blog/introducing-triggers-and-functions/?utm_source=redisinsight&utm_medium=main&utm_campaign=main">
Triggers and Functions
</a>
tool
</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.32.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/integrate/redisvl/user-guide/query-filter/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Query and filter
</h1>
<p class="text-lg -mt-5 mb-10">
Query and filter with RedisVL
</p>
<p>
In this document, you will explore more complex queries that can be performed with RedisVL.
</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>
This document is a converted form of
<a href="https://github.com/RedisVentures/redisvl/blob/main/docs/user_guide/hybrid_queries_02.ipynb">
this Jupyter notebook
</a>
.
</div>
</div>
<p>
Before beginning, be sure of the following:
</p>
<ol>
<li>
You have installed RedisVL and have that environment activated.
</li>
<li>
You have a running Redis instance with the Redis Query Engine capability.
</li>
</ol>
<p>
The sample binary data is in
<a href="https://github.com/RedisVentures/redisvl/blob/main/docs/user_guide/hybrid_example_data.pkl">
this file on GitHub
</a>
.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">pickle</span>
</span></span><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">jupyterutils</span> <span class="kn">import</span> <span class="n">table_print</span><span class="p">,</span> <span class="n">result_print</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># load in the example data and printing utils</span>
</span></span><span class="line"><span class="cl"><span class="n">data</span> <span class="o">=</span> <span class="n">pickle</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="nb">open</span><span class="p">(</span><span class="s2">"hybrid_example_data.pkl"</span><span class="p">,</span> <span class="s2">"rb"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="n">table_print</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
</span></span></code></pre>
</div>
<table>
<tbody>
<tr>
<th>
user
</th>
<th>
age
</th>
<th>
job
</th>
<th>
credit_score
</th>
<th>
office_location
</th>
<th>
user_embedding
</th>
</tr>
<tr>
<td>
john
</td>
<td>
18
</td>
<td>
engineer
</td>
<td>
high
</td>
<td>
-122.4194,37.7749
</td>
<td>
b'\xcd\xcc\xcc=\xcd\xcc\xcc=\x00\x00\x00?'
</td>
</tr>
<tr>
<td>
derrick
</td>
<td>
14
</td>
<td>
doctor
</td>
<td>
low
</td>
<td>
-122.4194,37.7749
</td>
<td>
b'\xcd\xcc\xcc=\xcd\xcc\xcc=\x00\x00\x00?'
</td>
</tr>
<tr>
<td>
nancy
</td>
<td>
94
</td>
<td>
doctor
</td>
<td>
high
</td>
<td>
-122.4194,37.7749
</td>
<td>
b'333?\xcd\xcc\xcc=\x00\x00\x00?'
</td>
</tr>
<tr>
<td>
tyler
</td>
<td>
100
</td>
<td>
engineer
</td>
<td>
high
</td>
<td>
-122.0839,37.3861
</td>
<td>
b'\xcd\xcc\xcc=\xcd\xcc\xcc>\x00\x00\x00?'
</td>
</tr>
<tr>
<td>
tim
</td>
<td>
12
</td>
<td>
dermatologist
</td>
<td>
high
</td>
<td>
-122.0839,37.3861
</td>
<td>
b'\xcd\xcc\xcc>\xcd\xcc\xcc>\x00\x00\x00?'
</td>
</tr>
<tr>
<td>
taimur
</td>
<td>
15
</td>
<td>
CEO
</td>
<td>
low
</td>
<td>
-122.0839,37.3861
</td>
<td>
b'\x9a\x99\x19?\xcd\xcc\xcc=\x00\x00\x00?'
</td>
</tr>
<tr>
<td>
joe
</td>
<td>
35
</td>
<td>
dentist
</td>
<td>
medium
</td>
<td>
-122.0839,37.3861
</td>
<td>
b'fff?fff?\xcd\xcc\xcc='
</td>
</tr>
</tbody>
</table>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">schema</span> <span class="o">=</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"index"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"name"</span><span class="p">:</span> <span class="s2">"user_queries"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"prefix"</span><span class="p">:</span> <span class="s2">"user_queries_docs"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"storage_type"</span><span class="p">:</span> <span class="s2">"hash"</span><span class="p">,</span> <span class="c1"># default setting -- HASH</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"fields"</span><span class="p">:</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span><span class="s2">"name"</span><span class="p">:</span> <span class="s2">"user"</span><span class="p">,</span> <span class="s2">"type"</span><span class="p">:</span> <span class="s2">"tag"</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span><span class="s2">"name"</span><span class="p">:</span> <span class="s2">"credit_score"</span><span class="p">,</span> <span class="s2">"type"</span><span class="p">:</span> <span class="s2">"tag"</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span><span class="s2">"name"</span><span class="p">:</span> <span class="s2">"job"</span><span class="p">,</span> <span class="s2">"type"</span><span class="p">:</span> <span class="s2">"text"</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span><span class="s2">"name"</span><span class="p">:</span> <span class="s2">"age"</span><span class="p">,</span> <span class="s2">"type"</span><span class="p">:</span> <span class="s2">"numeric"</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span><span class="s2">"name"</span><span class="p">:</span> <span class="s2">"office_location"</span><span class="p">,</span> <span class="s2">"type"</span><span class="p">:</span> <span class="s2">"geo"</span><span class="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">"name"</span><span class="p">:</span> <span class="s2">"user_embedding"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"type"</span><span class="p">:</span> <span class="s2">"vector"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"attrs"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"dims"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"distance_metric"</span><span class="p">:</span> <span class="s2">"cosine"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"algorithm"</span><span class="p">:</span> <span class="s2">"flat"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"datatype"</span><span class="p">:</span> <span class="s2">"float32"</span>
</span></span><span class="line"><span class="cl"> <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 class="p">],</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redisvl.index</span> <span class="kn">import</span> <span class="n">SearchIndex</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># construct a search index from the schema</span>
</span></span><span class="line"><span class="cl"><span class="n">index</span> <span class="o">=</span> <span class="n">SearchIndex</span><span class="o">.</span><span class="n">from_dict</span><span class="p">(</span><span class="n">schema</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># connect to local redis instance</span>
</span></span><span class="line"><span class="cl"><span class="n">index</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="s2">"redis://localhost:6379"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># create the index (no data yet)</span>
</span></span><span class="line"><span class="cl"><span class="n">index</span><span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="n">overwrite</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
</span></span></code></pre>
</div>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="c1"># inspect the newly-created index</span>
</span></span><span class="line"><span class="cl"><span class="err">$</span> <span class="n">rvl</span> <span class="n">index</span> <span class="n">listall</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="mi">18</span><span class="p">:</span><span class="mi">26</span><span class="p">:</span><span class="mi">34</span> <span class="p">[</span><span class="n">RedisVL</span><span class="p">]</span> <span class="n">INFO</span> <span class="n">Indices</span><span class="p">:</span>
</span></span><span class="line"><span class="cl"><span class="mi">18</span><span class="p">:</span><span class="mi">26</span><span class="p">:</span><span class="mi">34</span> <span class="p">[</span><span class="n">RedisVL</span><span class="p">]</span> <span class="n">INFO</span> <span class="mf">1.</span> <span class="n">user_queries</span>
</span></span></code></pre>
</div>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">keys</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
</span></span></code></pre>
</div>
<h2 id="hybrid-queries">
Hybrid queries
</h2>
<p>
Hybrid queries are queries that combine multiple types of filters. For example, you may want to search for a user that is a certain age, has a certain job, and is within a certain distance of a location. This is a hybrid query that combines numeric, tag, and geographic filters.
</p>
<h3 id="tag-filters">
Tag filters
</h3>
<p>
Tag filters are filters that are applied to tag fields. These are fields that are not tokenized and are used to store a single categorical value.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redisvl.query</span> <span class="kn">import</span> <span class="n">VectorQuery</span>
</span></span><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redisvl.query.filter</span> <span class="kn">import</span> <span class="n">Tag</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">t</span> <span class="o">=</span> <span class="n">Tag</span><span class="p">(</span><span class="s2">"credit_score"</span><span class="p">)</span> <span class="o">==</span> <span class="s2">"high"</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">v</span> <span class="o">=</span> <span class="n">VectorQuery</span><span class="p">([</span><span class="mf">0.1</span><span class="p">,</span> <span class="mf">0.1</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="s2">"user_embedding"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">return_fields</span><span class="o">=</span><span class="p">[</span><span class="s2">"user"</span><span class="p">,</span> <span class="s2">"credit_score"</span><span class="p">,</span> <span class="s2">"age"</span><span class="p">,</span> <span class="s2">"job"</span><span class="p">,</span> <span class="s2">"office_location"</span><span class="p">],</span>
</span></span><span class="line"><span class="cl"> <span class="n">filter_expression</span><span class="o">=</span><span class="n">t</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">results</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">v</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">result_print</span><span class="p">(</span><span class="n">results</span><span class="p">)</span>
</span></span></code></pre>
</div>
<table>
<tbody>
<tr>
<th>
vector_distance
</th>
<th>
user
</th>
<th>
credit_score
</th>
<th>
age
</th>
<th>
job
</th>
<th>
office_location
</th>
</tr>
<tr>
<td>
0
</td>
<td>
john
</td>
<td>
high
</td>
<td>
18
</td>
<td>
engineer
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.109129190445
</td>
<td>
tyler
</td>
<td>
high
</td>
<td>
100
</td>
<td>
engineer
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.158808946609
</td>
<td>
tim
</td>
<td>
high
</td>
<td>
12
</td>
<td>
dermatologist
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.266666650772
</td>
<td>
nancy
</td>
<td>
high
</td>
<td>
94
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
</tbody>
</table>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="c1"># negation</span>
</span></span><span class="line"><span class="cl"><span class="n">t</span> <span class="o">=</span> <span class="n">Tag</span><span class="p">(</span><span class="s2">"credit_score"</span><span class="p">)</span> <span class="o">!=</span> <span class="s2">"high"</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">v</span><span class="o">.</span><span class="n">set_filter</span><span class="p">(</span><span class="n">t</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">result_print</span><span class="p">(</span><span class="n">index</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>
</span></span></code></pre>
</div>
<table>
<tbody>
<tr>
<th>
vector_distance
</th>
<th>
user
</th>
<th>
credit_score
</th>
<th>
age
</th>
<th>
job
</th>
<th>
office_location
</th>
</tr>
<tr>
<td>
0
</td>
<td>
derrick
</td>
<td>
low
</td>
<td>
14
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.217882037163
</td>
<td>
taimur
</td>
<td>
low
</td>
<td>
15
</td>
<td>
CEO
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.653301358223
</td>
<td>
joe
</td>
<td>
medium
</td>
<td>
35
</td>
<td>
dentist
</td>
<td>
-122.0839,37.3861
</td>
</tr>
</tbody>
</table>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="c1"># use multiple tags as a list</span>
</span></span><span class="line"><span class="cl"><span class="n">t</span> <span class="o">=</span> <span class="n">Tag</span><span class="p">(</span><span class="s2">"credit_score"</span><span class="p">)</span> <span class="o">==</span> <span class="p">[</span><span class="s2">"high"</span><span class="p">,</span> <span class="s2">"medium"</span><span class="p">]</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">v</span><span class="o">.</span><span class="n">set_filter</span><span class="p">(</span><span class="n">t</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">result_print</span><span class="p">(</span><span class="n">index</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>
</span></span></code></pre>
</div>
<table>
<tbody>
<tr>
<th>
vector_distance
</th>
<th>
user
</th>
<th>
credit_score
</th>
<th>
age
</th>
<th>
job
</th>
<th>
office_location
</th>
</tr>
<tr>
<td>
0
</td>
<td>
john
</td>
<td>
high
</td>
<td>
18
</td>
<td>
engineer
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.109129190445
</td>
<td>
tyler
</td>
<td>
high
</td>
<td>
100
</td>
<td>
engineer
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.158808946609
</td>
<td>
tim
</td>
<td>
high
</td>
<td>
12
</td>
<td>
dermatologist
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.266666650772
</td>
<td>
nancy
</td>
<td>
high
</td>
<td>
94
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.653301358223
</td>
<td>
joe
</td>
<td>
medium
</td>
<td>
35
</td>
<td>
dentist
</td>
<td>
-122.0839,37.3861
</td>
</tr>
</tbody>
</table>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="c1"># use multiple tags as a set (to enforce uniqueness)</span>
</span></span><span class="line"><span class="cl"><span class="n">t</span> <span class="o">=</span> <span class="n">Tag</span><span class="p">(</span><span class="s2">"credit_score"</span><span class="p">)</span> <span class="o">==</span> <span class="nb">set</span><span class="p">([</span><span class="s2">"high"</span><span class="p">,</span> <span class="s2">"high"</span><span class="p">,</span> <span class="s2">"medium"</span><span class="p">])</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">v</span><span class="o">.</span><span class="n">set_filter</span><span class="p">(</span><span class="n">t</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">result_print</span><span class="p">(</span><span class="n">index</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>
</span></span></code></pre>
</div>
<table>
<tbody>
<tr>
<th>
vector_distance
</th>
<th>
user
</th>
<th>
credit_score
</th>
<th>
age
</th>
<th>
job
</th>
<th>
office_location
</th>
</tr>
<tr>
<td>
0
</td>
<td>
john
</td>
<td>
high
</td>
<td>
18
</td>
<td>
engineer
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.109129190445
</td>
<td>
tyler
</td>
<td>
high
</td>
<td>
100
</td>
<td>
engineer
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.158808946609
</td>
<td>
tim
</td>
<td>
high
</td>
<td>
12
</td>
<td>
dermatologist
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.266666650772
</td>
<td>
nancy
</td>
<td>
high
</td>
<td>
94
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.653301358223
</td>
<td>
joe
</td>
<td>
medium
</td>
<td>
35
</td>
<td>
dentist
</td>
<td>
-122.0839,37.3861
</td>
</tr>
</tbody>
</table>
<p>
What about scenarios where you might want to dynamically generate a list of tags? RedisVL allows you to do this gracefully without having to check for the empty case. The empty case is when you attempt to run a tag filter on a field with no defined values to match. For example:
</p>
<p>
<code>
Tag("credit_score") == []
</code>
</p>
<p>
An empty filter like the one above will yield a
<code>
*
</code>
Redis query filter that implies the base case: no filter.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="c1"># gracefully fallback to "*" filter if empty case</span>
</span></span><span class="line"><span class="cl"><span class="n">empty_case</span> <span class="o">=</span> <span class="n">Tag</span><span class="p">(</span><span class="s2">"credit_score"</span><span class="p">)</span> <span class="o">==</span> <span class="p">[]</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">v</span><span class="o">.</span><span class="n">set_filter</span><span class="p">(</span><span class="n">empty_case</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">result_print</span><span class="p">(</span><span class="n">index</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>
</span></span></code></pre>
</div>
<table>
<tbody>
<tr>
<th>
vector_distance
</th>
<th>
user
</th>
<th>
credit_score
</th>
<th>
age
</th>
<th>
job
</th>
<th>
office_location
</th>
</tr>
<tr>
<td>
0
</td>
<td>
john
</td>
<td>
high
</td>
<td>
18
</td>
<td>
engineer
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0
</td>
<td>
derrick
</td>
<td>
low
</td>
<td>
14
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.109129190445
</td>
<td>
tyler
</td>
<td>
high
</td>
<td>
100
</td>
<td>
engineer
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.158808946609
</td>
<td>
tim
</td>
<td>
high
</td>
<td>
12
</td>
<td>
dermatologist
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.217882037163
</td>
<td>
taimur
</td>
<td>
low
</td>
<td>
15
</td>
<td>
CEO
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.266666650772
</td>
<td>
nancy
</td>
<td>
high
</td>
<td>
94
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.653301358223
</td>
<td>
joe
</td>
<td>
medium
</td>
<td>
35
</td>
<td>
dentist
</td>
<td>
-122.0839,37.3861
</td>
</tr>
</tbody>
</table>
<h3 id="numeric-filters">
Numeric filters
</h3>
<p>
Numeric filters are filters that are applied to numeric fields and can be used to isolate a range of values for a given field.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redisvl.query.filter</span> <span class="kn">import</span> <span class="n">Num</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">numeric_filter</span> <span class="o">=</span> <span class="n">Num</span><span class="p">(</span><span class="s2">"age"</span><span class="p">)</span> <span class="o">></span> <span class="mi">15</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">v</span><span class="o">.</span><span class="n">set_filter</span><span class="p">(</span><span class="n">numeric_filter</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">result_print</span><span class="p">(</span><span class="n">index</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>
</span></span></code></pre>
</div>
<table>
<tbody>
<tr>
<th>
vector_distance
</th>
<th>
user
</th>
<th>
credit_score
</th>
<th>
age
</th>
<th>
job
</th>
<th>
office_location
</th>
</tr>
<tr>
<td>
0
</td>
<td>
john
</td>
<td>
high
</td>
<td>
18
</td>
<td>
engineer
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.109129190445
</td>
<td>
tyler
</td>
<td>
high
</td>
<td>
100
</td>
<td>
engineer
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.266666650772
</td>
<td>
nancy
</td>
<td>
high
</td>
<td>
94
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.653301358223
</td>
<td>
joe
</td>
<td>
medium
</td>
<td>
35
</td>
<td>
dentist
</td>
<td>
-122.0839,37.3861
</td>
</tr>
</tbody>
</table>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="c1"># exact match query</span>
</span></span><span class="line"><span class="cl"><span class="n">numeric_filter</span> <span class="o">=</span> <span class="n">Num</span><span class="p">(</span><span class="s2">"age"</span><span class="p">)</span> <span class="o">==</span> <span class="mi">14</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">v</span><span class="o">.</span><span class="n">set_filter</span><span class="p">(</span><span class="n">numeric_filter</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">result_print</span><span class="p">(</span><span class="n">index</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>
</span></span></code></pre>
</div>
<table>
<tbody>
<tr>
<th>
vector_distance
</th>
<th>
user
</th>
<th>
credit_score
</th>
<th>
age
</th>
<th>
job
</th>
<th>
office_location
</th>
</tr>
<tr>
<td>
0
</td>
<td>
derrick
</td>
<td>
low
</td>
<td>
14
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
</tbody>
</table>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="c1"># negation</span>
</span></span><span class="line"><span class="cl"><span class="n">numeric_filter</span> <span class="o">=</span> <span class="n">Num</span><span class="p">(</span><span class="s2">"age"</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">14</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">v</span><span class="o">.</span><span class="n">set_filter</span><span class="p">(</span><span class="n">numeric_filter</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">result_print</span><span class="p">(</span><span class="n">index</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>
</span></span></code></pre>
</div>
<table>
<tbody>
<tr>
<th>
vector_distance
</th>
<th>
user
</th>
<th>
credit_score
</th>
<th>
age
</th>
<th>
job
</th>
<th>
office_location
</th>
</tr>
<tr>
<td>
0
</td>
<td>
john
</td>
<td>
high
</td>
<td>
18
</td>
<td>
engineer
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.109129190445
</td>
<td>
tyler
</td>
<td>
high
</td>
<td>
100
</td>
<td>
engineer
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.158808946609
</td>
<td>
tim
</td>
<td>
high
</td>
<td>
12
</td>
<td>
dermatologist
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.217882037163
</td>
<td>
taimur
</td>
<td>
low
</td>
<td>
15
</td>
<td>
CEO
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.266666650772
</td>
<td>
nancy
</td>
<td>
high
</td>
<td>
94
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.653301358223
</td>
<td>
joe
</td>
<td>
medium
</td>
<td>
35
</td>
<td>
dentist
</td>
<td>
-122.0839,37.3861
</td>
</tr>
</tbody>
</table>
<h3 id="text-filters">
Text filters
</h3>
<p>
Text filters are filters that are applied to text fields. These filters are applied to the entire text field. For example, if you have a text field that contains the text "The quick brown fox jumps over the lazy dog", a text filter of "quick" will match this text field.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redisvl.query.filter</span> <span class="kn">import</span> <span class="n">Text</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># exact match filter -- document must contain the exact word doctor</span>
</span></span><span class="line"><span class="cl"><span class="n">text_filter</span> <span class="o">=</span> <span class="n">Text</span><span class="p">(</span><span class="s2">"job"</span><span class="p">)</span> <span class="o">==</span> <span class="s2">"doctor"</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">v</span><span class="o">.</span><span class="n">set_filter</span><span class="p">(</span><span class="n">text_filter</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">result_print</span><span class="p">(</span><span class="n">index</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>
</span></span></code></pre>
</div>
<table>
<tbody>
<tr>
<th>
vector_distance
</th>
<th>
user
</th>
<th>
credit_score
</th>
<th>
age
</th>
<th>
job
</th>
<th>
office_location
</th>
</tr>
<tr>
<td>
0
</td>
<td>
derrick
</td>
<td>
low
</td>
<td>
14
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.266666650772
</td>
<td>
nancy
</td>
<td>
high
</td>
<td>
94
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
</tbody>
</table>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="c1"># negation -- document must not contain the exact word doctor</span>
</span></span><span class="line"><span class="cl"><span class="n">negate_text_filter</span> <span class="o">=</span> <span class="n">Text</span><span class="p">(</span><span class="s2">"job"</span><span class="p">)</span> <span class="o">!=</span> <span class="s2">"doctor"</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">v</span><span class="o">.</span><span class="n">set_filter</span><span class="p">(</span><span class="n">negate_text_filter</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">result_print</span><span class="p">(</span><span class="n">index</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>
</span></span></code></pre>
</div>
<table>
<tbody>
<tr>
<th>
vector_distance
</th>
<th>
user
</th>
<th>
credit_score
</th>
<th>
age
</th>
<th>
job
</th>
<th>
office_location
</th>
</tr>
<tr>
<td>
0
</td>
<td>
john
</td>
<td>
high
</td>
<td>
18
</td>
<td>
engineer
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.109129190445
</td>
<td>
tyler
</td>
<td>
high
</td>
<td>
100
</td>
<td>
engineer
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.158808946609
</td>
<td>
tim
</td>
<td>
high
</td>
<td>
12
</td>
<td>
dermatologist
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.217882037163
</td>
<td>
taimur
</td>
<td>
low
</td>
<td>
15
</td>
<td>
CEO
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.653301358223
</td>
<td>
joe
</td>
<td>
medium
</td>
<td>
35
</td>
<td>
dentist
</td>
<td>
-122.0839,37.3861
</td>
</tr>
</tbody>
</table>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="c1"># wildcard match filter</span>
</span></span><span class="line"><span class="cl"><span class="n">wildcard_filter</span> <span class="o">=</span> <span class="n">Text</span><span class="p">(</span><span class="s2">"job"</span><span class="p">)</span> <span class="o">%</span> <span class="s2">"doct*"</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">v</span><span class="o">.</span><span class="n">set_filter</span><span class="p">(</span><span class="n">wildcard_filter</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">result_print</span><span class="p">(</span><span class="n">index</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>
</span></span></code></pre>
</div>
<table>
<tbody>
<tr>
<th>
vector_distance
</th>
<th>
user
</th>
<th>
credit_score
</th>
<th>
age
</th>
<th>
job
</th>
<th>
office_location
</th>
</tr>
<tr>
<td>
0
</td>
<td>
derrick
</td>
<td>
low
</td>
<td>
14
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.266666650772
</td>
<td>
nancy
</td>
<td>
high
</td>
<td>
94
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
</tbody>
</table>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="c1"># fuzzy match filter</span>
</span></span><span class="line"><span class="cl"><span class="n">fuzzy_match</span> <span class="o">=</span> <span class="n">Text</span><span class="p">(</span><span class="s2">"job"</span><span class="p">)</span> <span class="o">%</span> <span class="s2">"</span><span class="si">%%</span><span class="s2">engine</span><span class="si">%%</span><span class="s2">"</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">v</span><span class="o">.</span><span class="n">set_filter</span><span class="p">(</span><span class="n">fuzzy_match</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">result_print</span><span class="p">(</span><span class="n">index</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>
</span></span></code></pre>
</div>
<table>
<tbody>
<tr>
<th>
vector_distance
</th>
<th>
user
</th>
<th>
credit_score
</th>
<th>
age
</th>
<th>
job
</th>
<th>
office_location
</th>
</tr>
<tr>
<td>
0
</td>
<td>
john
</td>
<td>
high
</td>
<td>
18
</td>
<td>
engineer
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.109129190445
</td>
<td>
tyler
</td>
<td>
high
</td>
<td>
100
</td>
<td>
engineer
</td>
<td>
-122.0839,37.3861
</td>
</tr>
</tbody>
</table>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="c1"># conditional -- match documents with job field containing engineer OR doctor</span>
</span></span><span class="line"><span class="cl"><span class="n">conditional</span> <span class="o">=</span> <span class="n">Text</span><span class="p">(</span><span class="s2">"job"</span><span class="p">)</span> <span class="o">%</span> <span class="s2">"engineer|doctor"</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">v</span><span class="o">.</span><span class="n">set_filter</span><span class="p">(</span><span class="n">conditional</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">result_print</span><span class="p">(</span><span class="n">index</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>
</span></span></code></pre>
</div>
<table>
<tbody>
<tr>
<th>
vector_distance
</th>
<th>
user
</th>
<th>
credit_score
</th>
<th>
age
</th>
<th>
job
</th>
<th>
office_location
</th>
</tr>
<tr>
<td>
0
</td>
<td>
john
</td>
<td>
high
</td>
<td>
18
</td>
<td>
engineer
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0
</td>
<td>
derrick
</td>
<td>
low
</td>
<td>
14
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.109129190445
</td>
<td>
tyler
</td>
<td>
high
</td>
<td>
100
</td>
<td>
engineer
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.266666650772
</td>
<td>
nancy
</td>
<td>
high
</td>
<td>
94
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
</tbody>
</table>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="c1"># gracefully fallback to "*" filter if empty case</span>
</span></span><span class="line"><span class="cl"><span class="n">empty_case</span> <span class="o">=</span> <span class="n">Text</span><span class="p">(</span><span class="s2">"job"</span><span class="p">)</span> <span class="o">%</span> <span class="s2">""</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">v</span><span class="o">.</span><span class="n">set_filter</span><span class="p">(</span><span class="n">empty_case</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">result_print</span><span class="p">(</span><span class="n">index</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>
</span></span></code></pre>
</div>
<table>
<tbody>
<tr>
<th>
vector_distance
</th>
<th>
user
</th>
<th>
credit_score
</th>
<th>
age
</th>
<th>
job
</th>
<th>
office_location
</th>
</tr>
<tr>
<td>
0
</td>
<td>
john
</td>
<td>
high
</td>
<td>
18
</td>
<td>
engineer
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0
</td>
<td>
derrick
</td>
<td>
low
</td>
<td>
14
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.109129190445
</td>
<td>
tyler
</td>
<td>
high
</td>
<td>
100
</td>
<td>
engineer
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.158808946609
</td>
<td>
tim
</td>
<td>
high
</td>
<td>
12
</td>
<td>
dermatologist
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.217882037163
</td>
<td>
taimur
</td>
<td>
low
</td>
<td>
15
</td>
<td>
CEO
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.266666650772
</td>
<td>
nancy
</td>
<td>
high
</td>
<td>
94
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.653301358223
</td>
<td>
joe
</td>
<td>
medium
</td>
<td>
35
</td>
<td>
dentist
</td>
<td>
-122.0839,37.3861
</td>
</tr>
</tbody>
</table>
<h3 id="geographic-filters">
Geographic filters
</h3>
<p>
Geographic filters are filters that are applied to geographic fields. These filters are used to find results that are within a certain distance of a given point. The distance is specified in kilometers, miles, meters, or feet. A radius can also be specified to find results within a certain radius of a given point.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redisvl.query.filter</span> <span class="kn">import</span> <span class="n">Geo</span><span class="p">,</span> <span class="n">GeoRadius</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># within 10 km of San Francisco office</span>
</span></span><span class="line"><span class="cl"><span class="n">geo_filter</span> <span class="o">=</span> <span class="n">Geo</span><span class="p">(</span><span class="s2">"office_location"</span><span class="p">)</span> <span class="o">==</span> <span class="n">GeoRadius</span><span class="p">(</span><span class="o">-</span><span class="mf">122.4194</span><span class="p">,</span> <span class="mf">37.7749</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="s2">"km"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">v</span><span class="o">.</span><span class="n">set_filter</span><span class="p">(</span><span class="n">geo_filter</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">result_print</span><span class="p">(</span><span class="n">index</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>
</span></span></code></pre>
</div>
<table>
<tbody>
<tr>
<th>
vector_distance
</th>
<th>
user
</th>
<th>
credit_score
</th>
<th>
age
</th>
<th>
job
</th>
<th>
office_location
</th>
</tr>
<tr>
<td>
0
</td>
<td>
john
</td>
<td>
high
</td>
<td>
18
</td>
<td>
engineer
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0
</td>
<td>
derrick
</td>
<td>
low
</td>
<td>
14
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.266666650772
</td>
<td>
nancy
</td>
<td>
high
</td>
<td>
94
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
</tbody>
</table>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="c1"># within 100 km Radius of San Francisco office</span>
</span></span><span class="line"><span class="cl"><span class="n">geo_filter</span> <span class="o">=</span> <span class="n">Geo</span><span class="p">(</span><span class="s2">"office_location"</span><span class="p">)</span> <span class="o">==</span> <span class="n">GeoRadius</span><span class="p">(</span><span class="o">-</span><span class="mf">122.4194</span><span class="p">,</span> <span class="mf">37.7749</span><span class="p">,</span> <span class="mi">100</span><span class="p">,</span> <span class="s2">"km"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">v</span><span class="o">.</span><span class="n">set_filter</span><span class="p">(</span><span class="n">geo_filter</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">result_print</span><span class="p">(</span><span class="n">index</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>
</span></span></code></pre>
</div>
<table>
<tbody>
<tr>
<th>
vector_distance
</th>
<th>
user
</th>
<th>
credit_score
</th>
<th>
age
</th>
<th>
job
</th>
<th>
office_location
</th>
</tr>
<tr>
<td>
0
</td>
<td>
john
</td>
<td>
high
</td>
<td>
18
</td>
<td>
engineer
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0
</td>
<td>
derrick
</td>
<td>
low
</td>
<td>
14
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.109129190445
</td>
<td>
tyler
</td>
<td>
high
</td>
<td>
100
</td>
<td>
engineer
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.158808946609
</td>
<td>
tim
</td>
<td>
high
</td>
<td>
12
</td>
<td>
dermatologist
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.217882037163
</td>
<td>
taimur
</td>
<td>
low
</td>
<td>
15
</td>
<td>
CEO
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.266666650772
</td>
<td>
nancy
</td>
<td>
high
</td>
<td>
94
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.653301358223
</td>
<td>
joe
</td>
<td>
medium
</td>
<td>
35
</td>
<td>
dentist
</td>
<td>
-122.0839,37.3861
</td>
</tr>
</tbody>
</table>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="c1"># not within 10 km Radius of San Francisco office</span>
</span></span><span class="line"><span class="cl"><span class="n">geo_filter</span> <span class="o">=</span> <span class="n">Geo</span><span class="p">(</span><span class="s2">"office_location"</span><span class="p">)</span> <span class="o">!=</span> <span class="n">GeoRadius</span><span class="p">(</span><span class="o">-</span><span class="mf">122.4194</span><span class="p">,</span> <span class="mf">37.7749</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="s2">"km"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">v</span><span class="o">.</span><span class="n">set_filter</span><span class="p">(</span><span class="n">geo_filter</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">result_print</span><span class="p">(</span><span class="n">index</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>
</span></span></code></pre>
</div>
<table>
<tbody>
<tr>
<th>
vector_distance
</th>
<th>
user
</th>
<th>
credit_score
</th>
<th>
age
</th>
<th>
job
</th>
<th>
office_location
</th>
</tr>
<tr>
<td>
0.109129190445
</td>
<td>
tyler
</td>
<td>
high
</td>
<td>
100
</td>
<td>
engineer
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.158808946609
</td>
<td>
tim
</td>
<td>
high
</td>
<td>
12
</td>
<td>
dermatologist
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.217882037163
</td>
<td>
taimur
</td>
<td>
low
</td>
<td>
15
</td>
<td>
CEO
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.653301358223
</td>
<td>
joe
</td>
<td>
medium
</td>
<td>
35
</td>
<td>
dentist
</td>
<td>
-122.0839,37.3861
</td>
</tr>
</tbody>
</table>
<h2 id="combining-filters">
Combining Filters
</h2>
<p>
In this example, you will combine a numeric filter with a tag filter, and search for users that are between the ages of 20 and 30 and have a job title of "engineer".
</p>
<h3 id="intersection-and">
Intersection ("and")
</h3>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">t</span> <span class="o">=</span> <span class="n">Tag</span><span class="p">(</span><span class="s2">"credit_score"</span><span class="p">)</span> <span class="o">==</span> <span class="s2">"high"</span>
</span></span><span class="line"><span class="cl"><span class="n">low</span> <span class="o">=</span> <span class="n">Num</span><span class="p">(</span><span class="s2">"age"</span><span class="p">)</span> <span class="o">>=</span> <span class="mi">18</span>
</span></span><span class="line"><span class="cl"><span class="n">high</span> <span class="o">=</span> <span class="n">Num</span><span class="p">(</span><span class="s2">"age"</span><span class="p">)</span> <span class="o"><=</span> <span class="mi">100</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">combined</span> <span class="o">=</span> <span class="n">t</span> <span class="o">&</span> <span class="n">low</span> <span class="o">&</span> <span class="n">high</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">v</span> <span class="o">=</span> <span class="n">VectorQuery</span><span class="p">([</span><span class="mf">0.1</span><span class="p">,</span> <span class="mf">0.1</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="s2">"user_embedding"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">return_fields</span><span class="o">=</span><span class="p">[</span><span class="s2">"user"</span><span class="p">,</span> <span class="s2">"credit_score"</span><span class="p">,</span> <span class="s2">"age"</span><span class="p">,</span> <span class="s2">"job"</span><span class="p">,</span> <span class="s2">"office_location"</span><span class="p">],</span>
</span></span><span class="line"><span class="cl"> <span class="n">filter_expression</span><span class="o">=</span><span class="n">combined</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">result_print</span><span class="p">(</span><span class="n">index</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>
</span></span></code></pre>
</div>
<table>
<tbody>
<tr>
<th>
vector_distance
</th>
<th>
user
</th>
<th>
credit_score
</th>
<th>
age
</th>
<th>
job
</th>
<th>
office_location
</th>
</tr>
<tr>
<td>
0
</td>
<td>
john
</td>
<td>
high
</td>
<td>
18
</td>
<td>
engineer
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.109129190445
</td>
<td>
tyler
</td>
<td>
high
</td>
<td>
100
</td>
<td>
engineer
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.266666650772
</td>
<td>
nancy
</td>
<td>
high
</td>
<td>
94
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
</tbody>
</table>
<h3 id="union-or">
Union ("or")
</h3>
<p>
The union of two queries is the set of all results that are returned by either of the two queries. The union of two queries is performed using the
<code>
|
</code>
operator.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">low</span> <span class="o">=</span> <span class="n">Num</span><span class="p">(</span><span class="s2">"age"</span><span class="p">)</span> <span class="o"><</span> <span class="mi">18</span>
</span></span><span class="line"><span class="cl"><span class="n">high</span> <span class="o">=</span> <span class="n">Num</span><span class="p">(</span><span class="s2">"age"</span><span class="p">)</span> <span class="o">></span> <span class="mi">93</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">combined</span> <span class="o">=</span> <span class="n">low</span> <span class="o">|</span> <span class="n">high</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">v</span><span class="o">.</span><span class="n">set_filter</span><span class="p">(</span><span class="n">combined</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">result_print</span><span class="p">(</span><span class="n">index</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>
</span></span></code></pre>
</div>
<table>
<tbody>
<tr>
<th>
vector_distance
</th>
<th>
user
</th>
<th>
credit_score
</th>
<th>
age
</th>
<th>
job
</th>
<th>
office_location
</th>
</tr>
<tr>
<td>
0
</td>
<td>
derrick
</td>
<td>
low
</td>
<td>
14
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.109129190445
</td>
<td>
tyler
</td>
<td>
high
</td>
<td>
100
</td>
<td>
engineer
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.158808946609
</td>
<td>
tim
</td>
<td>
high
</td>
<td>
12
</td>
<td>
dermatologist
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.217882037163
</td>
<td>
taimur
</td>
<td>
low
</td>
<td>
15
</td>
<td>
CEO
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.266666650772
</td>
<td>
nancy
</td>
<td>
high
</td>
<td>
94
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
</tbody>
</table>
<h3 id="dynamic-combination">
Dynamic combination
</h3>
<p>
There are often situations where you may or may not want to use a filter in a
given query. As shown above, filters will except the
<code>
None
</code>
type and revert
to a wildcard filter that returns all results.
</p>
<p>
The same goes for filter combinations, which enable rapid reuse of filters in
requests with different parameters as shown below. This removes the need for
a number of "if-then" conditionals to test for the empty case.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="k">def</span> <span class="nf">make_filter</span><span class="p">(</span><span class="n">age</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">credit</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">job</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
</span></span><span class="line"><span class="cl"> <span class="n">flexible_filter</span> <span class="o">=</span> <span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="p">(</span><span class="n">Num</span><span class="p">(</span><span class="s2">"age"</span><span class="p">)</span> <span class="o">></span> <span class="n">age</span><span class="p">)</span> <span class="o">&</span>
</span></span><span class="line"><span class="cl"> <span class="p">(</span><span class="n">Tag</span><span class="p">(</span><span class="s2">"credit_score"</span><span class="p">)</span> <span class="o">==</span> <span class="n">credit</span><span class="p">)</span> <span class="o">&</span>
</span></span><span class="line"><span class="cl"> <span class="p">(</span><span class="n">Text</span><span class="p">(</span><span class="s2">"job"</span><span class="p">)</span> <span class="o">%</span> <span class="n">job</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="k">return</span> <span class="n">flexible_filter</span>
</span></span></code></pre>
</div>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="c1"># all parameters</span>
</span></span><span class="line"><span class="cl"><span class="n">combined</span> <span class="o">=</span> <span class="n">make_filter</span><span class="p">(</span><span class="n">age</span><span class="o">=</span><span class="mi">18</span><span class="p">,</span> <span class="n">credit</span><span class="o">=</span><span class="s2">"high"</span><span class="p">,</span> <span class="n">job</span><span class="o">=</span><span class="s2">"engineer"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">v</span><span class="o">.</span><span class="n">set_filter</span><span class="p">(</span><span class="n">combined</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">result_print</span><span class="p">(</span><span class="n">index</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>
</span></span></code></pre>
</div>
<table>
<tbody>
<tr>
<th>
vector_distance
</th>
<th>
user
</th>
<th>
credit_score
</th>
<th>
age
</th>
<th>
job
</th>
<th>
office_location
</th>
</tr>
<tr>
<td>
0.109129190445
</td>
<td>
tyler
</td>
<td>
high
</td>
<td>
100
</td>
<td>
engineer
</td>
<td>
-122.0839,37.3861
</td>
</tr>
</tbody>
</table>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="c1"># just age and credit_score</span>
</span></span><span class="line"><span class="cl"><span class="n">combined</span> <span class="o">=</span> <span class="n">make_filter</span><span class="p">(</span><span class="n">age</span><span class="o">=</span><span class="mi">18</span><span class="p">,</span> <span class="n">credit</span><span class="o">=</span><span class="s2">"high"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">v</span><span class="o">.</span><span class="n">set_filter</span><span class="p">(</span><span class="n">combined</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">result_print</span><span class="p">(</span><span class="n">index</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>
</span></span></code></pre>
</div>
<table>
<tbody>
<tr>
<th>
vector_distance
</th>
<th>
user
</th>
<th>
credit_score
</th>
<th>
age
</th>
<th>
job
</th>
<th>
office_location
</th>
</tr>
<tr>
<td>
0.109129190445
</td>
<td>
tyler
</td>
<td>
high
</td>
<td>
100
</td>
<td>
engineer
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.266666650772
</td>
<td>
nancy
</td>
<td>
high
</td>
<td>
94
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
</tbody>
</table>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="c1"># just age</span>
</span></span><span class="line"><span class="cl"><span class="n">combined</span> <span class="o">=</span> <span class="n">make_filter</span><span class="p">(</span><span class="n">age</span><span class="o">=</span><span class="mi">18</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">v</span><span class="o">.</span><span class="n">set_filter</span><span class="p">(</span><span class="n">combined</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">result_print</span><span class="p">(</span><span class="n">index</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>
</span></span></code></pre>
</div>
<table>
<tbody>
<tr>
<th>
vector_distance
</th>
<th>
user
</th>
<th>
credit_score
</th>
<th>
age
</th>
<th>
job
</th>
<th>
office_location
</th>
</tr>
<tr>
<td>
0.109129190445
</td>
<td>
tyler
</td>
<td>
high
</td>
<td>
100
</td>
<td>
engineer
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.266666650772
</td>
<td>
nancy
</td>
<td>
high
</td>
<td>
94
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.653301358223
</td>
<td>
joe
</td>
<td>
medium
</td>
<td>
35
</td>
<td>
dentist
</td>
<td>
-122.0839,37.3861
</td>
</tr>
</tbody>
</table>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="c1"># no filters</span>
</span></span><span class="line"><span class="cl"><span class="n">combined</span> <span class="o">=</span> <span class="n">make_filter</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"><span class="n">v</span><span class="o">.</span><span class="n">set_filter</span><span class="p">(</span><span class="n">combined</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">result_print</span><span class="p">(</span><span class="n">index</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>
</span></span></code></pre>
</div>
<table>
<tbody>
<tr>
<th>
vector_distance
</th>
<th>
user
</th>
<th>
credit_score
</th>
<th>
age
</th>
<th>
job
</th>
<th>
office_location
</th>
</tr>
<tr>
<td>
0
</td>
<td>
john
</td>
<td>
high
</td>
<td>
18
</td>
<td>
engineer
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0
</td>
<td>
derrick
</td>
<td>
low
</td>
<td>
14
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.109129190445
</td>
<td>
tyler
</td>
<td>
high
</td>
<td>
100
</td>
<td>
engineer
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.158808946609
</td>
<td>
tim
</td>
<td>
high
</td>
<td>
12
</td>
<td>
dermatologist
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.217882037163
</td>
<td>
taimur
</td>
<td>
low
</td>
<td>
15
</td>
<td>
CEO
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.266666650772
</td>
<td>
nancy
</td>
<td>
high
</td>
<td>
94
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.653301358223
</td>
<td>
joe
</td>
<td>
medium
</td>
<td>
35
</td>
<td>
dentist
</td>
<td>
-122.0839,37.3861
</td>
</tr>
</tbody>
</table>
<h2 id="filter-queries">
Filter queries
</h2>
<p>
In some cases, you may not want to run a vector query, but just use a
<code>
FilterExpression
</code>
similar to a SQL query. The
<code>
FilterQuery
</code>
class enable this functionality. It is similar to the
<code>
VectorQuery
</code>
class but soley takes a
<code>
FilterExpression
</code>
.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redisvl.query</span> <span class="kn">import</span> <span class="n">FilterQuery</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">has_low_credit</span> <span class="o">=</span> <span class="n">Tag</span><span class="p">(</span><span class="s2">"credit_score"</span><span class="p">)</span> <span class="o">==</span> <span class="s2">"low"</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">filter_query</span> <span class="o">=</span> <span class="n">FilterQuery</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="n">return_fields</span><span class="o">=</span><span class="p">[</span><span class="s2">"user"</span><span class="p">,</span> <span class="s2">"credit_score"</span><span class="p">,</span> <span class="s2">"age"</span><span class="p">,</span> <span class="s2">"job"</span><span class="p">,</span> <span class="s2">"location"</span><span class="p">],</span>
</span></span><span class="line"><span class="cl"> <span class="n">filter_expression</span><span class="o">=</span><span class="n">has_low_credit</span>
</span></span><span class="line"><span 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">results</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">filter_query</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">result_print</span><span class="p">(</span><span class="n">results</span><span class="p">)</span>
</span></span></code></pre>
</div>
<table>
<tbody>
<tr>
<th>
user
</th>
<th>
credit_score
</th>
<th>
age
</th>
<th>
job
</th>
</tr>
<tr>
<td>
derrick
</td>
<td>
low
</td>
<td>
14
</td>
<td>
doctor
</td>
</tr>
<tr>
<td>
taimur
</td>
<td>
low
</td>
<td>
15
</td>
<td>
CEO
</td>
</tr>
</tbody>
</table>
<h2 id="count-queries">
Count queries
</h2>
<p>
In some cases, you may need to use a
<code>
FilterExpression
</code>
to execute a
<code>
CountQuery
</code>
that simply returns the count of the number of entities in the pertaining set. It is similar to the
<code>
FilterQuery
</code>
class but does not return the values of the underlying data.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redisvl.query</span> <span class="kn">import</span> <span class="n">CountQuery</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">has_low_credit</span> <span class="o">=</span> <span class="n">Tag</span><span class="p">(</span><span class="s2">"credit_score"</span><span class="p">)</span> <span class="o">==</span> <span class="s2">"low"</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">filter_query</span> <span class="o">=</span> <span class="n">CountQuery</span><span class="p">(</span><span class="n">filter_expression</span><span class="o">=</span><span class="n">has_low_credit</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">count</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">filter_query</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="si">{</span><span class="n">count</span><span class="si">}</span><span class="s2"> records match the filter expression </span><span class="si">{</span><span class="nb">str</span><span class="p">(</span><span class="n">has_low_credit</span><span class="p">)</span><span class="si">}</span><span class="s2"> for the given index."</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="mi">2</span> <span class="n">records</span> <span class="n">match</span> <span class="n">the</span> <span class="nb">filter</span> <span class="n">expression</span> <span class="nd">@credit_score</span><span class="p">:{</span><span class="n">low</span><span class="p">}</span> <span class="k">for</span> <span class="n">the</span> <span class="n">given</span> <span class="n">index</span><span class="o">.</span>
</span></span></code></pre>
</div>
<h2 id="range-queries">
Range queries
</h2>
<p>
Range Queries are useful for performing a vector search where only the results within a vector
<code>
distance_threshold
</code>
are returned. This enables the user to find all records within their dataset that are similar to a query vector where "similar" is defined by a quantitative value.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redisvl.query</span> <span class="kn">import</span> <span class="n">RangeQuery</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">range_query</span> <span class="o">=</span> <span class="n">RangeQuery</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="n">vector</span><span class="o">=</span><span class="p">[</span><span class="mf">0.1</span><span class="p">,</span> <span class="mf">0.1</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="n">vector_field_name</span><span class="o">=</span><span class="s2">"user_embedding"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">return_fields</span><span class="o">=</span><span class="p">[</span><span class="s2">"user"</span><span class="p">,</span> <span class="s2">"credit_score"</span><span class="p">,</span> <span class="s2">"age"</span><span class="p">,</span> <span class="s2">"job"</span><span class="p">,</span> <span class="s2">"location"</span><span class="p">],</span>
</span></span><span class="line"><span class="cl"> <span class="n">distance_threshold</span><span class="o">=</span><span class="mf">0.2</span>
</span></span><span class="line"><span 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"># same as the vector query or filter query</span>
</span></span><span class="line"><span class="cl"><span class="n">results</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">range_query</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">result_print</span><span class="p">(</span><span class="n">results</span><span class="p">)</span>
</span></span></code></pre>
</div>
<table>
<tbody>
<tr>
<th>
vector_distance
</th>
<th>
user
</th>
<th>
credit_score
</th>
<th>
age
</th>
<th>
job
</th>
</tr>
<tr>
<td>
0
</td>
<td>
john
</td>
<td>
high
</td>
<td>
18
</td>
<td>
engineer
</td>
</tr>
<tr>
<td>
0
</td>
<td>
derrick
</td>
<td>
low
</td>
<td>
14
</td>
<td>
doctor
</td>
</tr>
<tr>
<td>
0.109129190445
</td>
<td>
tyler
</td>
<td>
high
</td>
<td>
100
</td>
<td>
engineer
</td>
</tr>
<tr>
<td>
0.158808946609
</td>
<td>
tim
</td>
<td>
high
</td>
<td>
12
</td>
<td>
dermatologist
</td>
</tr>
</tbody>
</table>
<p>
You can also change the distance threshold of the query object between uses. Here, you will set
<code>
distance_threshold==0.1
</code>
. This means that the query object will return all matches that are within 0.1 of the query object. This is a small distance, so expect to get fewer matches than before.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">range_query</span><span class="o">.</span><span class="n">set_distance_threshold</span><span class="p">(</span><span class="mf">0.1</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">result_print</span><span class="p">(</span><span class="n">index</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">range_query</span><span class="p">))</span>
</span></span></code></pre>
</div>
<table>
<tbody>
<tr>
<th>
vector_distance
</th>
<th>
user
</th>
<th>
credit_score
</th>
<th>
age
</th>
<th>
job
</th>
</tr>
<tr>
<td>
0
</td>
<td>
john
</td>
<td>
high
</td>
<td>
18
</td>
<td>
engineer
</td>
</tr>
<tr>
<td>
0
</td>
<td>
derrick
</td>
<td>
low
</td>
<td>
14
</td>
<td>
doctor
</td>
</tr>
</tbody>
</table>
<p>
Range queries can also be used with filters like any other query type. The following limits the results to only those records with a
<code>
job
</code>
of
<code>
engineer
</code>
while also being within the vector range (i.e., distance).
</p>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">is_engineer</span> <span class="o">=</span> <span class="n">Text</span><span class="p">(</span><span class="s2">"job"</span><span class="p">)</span> <span class="o">==</span> <span class="s2">"engineer"</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">range_query</span><span class="o">.</span><span class="n">set_filter</span><span class="p">(</span><span class="n">is_engineer</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">result_print</span><span class="p">(</span><span class="n">index</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">range_query</span><span class="p">))</span>
</span></span></code></pre>
</div>
<table>
<tbody>
<tr>
<th>
vector_distance
</th>
<th>
user
</th>
<th>
credit_score
</th>
<th>
age
</th>
<th>
job
</th>
</tr>
<tr>
<td>
0
</td>
<td>
john
</td>
<td>
high
</td>
<td>
18
</td>
<td>
engineer
</td>
</tr>
</tbody>
</table>
<h2 id="other-redis-queries">
Other Redis queries
</h2>
<p>
There may be cases where RedisVL does not cover the explicit functionality required by the query, either because of new releases that haven't been implemented in the client, or because of a very specific use case. In these cases, it is possible to use the
<code>
SearchIndex.search
</code>
method to execute queries with a redis-py
<code>
Query
</code>
object or through a raw Redis string.
</p>
<h3 id="redis-py">
redis-py
</h3>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="c1"># Manipulate the redis-py Query object</span>
</span></span><span class="line"><span class="cl"><span class="n">redis_py_query</span> <span class="o">=</span> <span class="n">v</span><span class="o">.</span><span class="n">query</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># choose to sort by age instead of vector distance</span>
</span></span><span class="line"><span class="cl"><span class="n">redis_py_query</span><span class="o">.</span><span class="n">sort_by</span><span class="p">(</span><span class="s2">"age"</span><span class="p">,</span> <span class="n">asc</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># run the query with the ``SearchIndex.search`` method</span>
</span></span><span class="line"><span class="cl"><span class="n">result</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">redis_py_query</span><span class="p">,</span> <span class="n">v</span><span class="o">.</span><span class="n">params</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">result_print</span><span class="p">(</span><span class="n">result</span><span class="p">)</span>
</span></span></code></pre>
</div>
<table>
<tbody>
<tr>
<th>
vector_distance
</th>
<th>
age
</th>
<th>
user
</th>
<th>
credit_score
</th>
<th>
job
</th>
<th>
office_location
</th>
</tr>
<tr>
<td>
0.109129190445
</td>
<td>
100
</td>
<td>
tyler
</td>
<td>
high
</td>
<td>
engineer
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0.266666650772
</td>
<td>
94
</td>
<td>
nancy
</td>
<td>
high
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.653301358223
</td>
<td>
35
</td>
<td>
joe
</td>
<td>
medium
</td>
<td>
dentist
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0
</td>
<td>
18
</td>
<td>
john
</td>
<td>
high
</td>
<td>
engineer
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.217882037163
</td>
<td>
15
</td>
<td>
taimur
</td>
<td>
low
</td>
<td>
CEO
</td>
<td>
-122.0839,37.3861
</td>
</tr>
<tr>
<td>
0
</td>
<td>
14
</td>
<td>
derrick
</td>
<td>
low
</td>
<td>
doctor
</td>
<td>
-122.4194,37.7749
</td>
</tr>
<tr>
<td>
0.158808946609
</td>
<td>
12
</td>
<td>
tim
</td>
<td>
high
</td>
<td>
dermatologist
</td>
<td>
-122.0839,37.3861
</td>
</tr>
</tbody>
</table>
<h3 id="raw-redis-query-string">
Raw Redis query string
</h3>
<p>
One case might be where you want to have a search that only filters on a tag field and doesn't need other functionality. Conversely, you may require a query that is more complex than what is currently supported by RedisVL. In these cases, you can use the
<code>
SearchIndex.search
</code>
method with a raw Redis query string.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">t</span> <span class="o">=</span> <span class="n">Tag</span><span class="p">(</span><span class="s2">"credit_score"</span><span class="p">)</span> <span class="o">==</span> <span class="s2">"high"</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="nb">str</span><span class="p">(</span><span class="n">t</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="s1">'@credit_score:</span><span class="si">{high}</span><span class="s1">'</span>
</span></span></code></pre>
</div>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">results</span> <span class="o">=</span> <span class="n">index</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">t</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="n">results</span><span class="o">.</span><span class="n">docs</span><span class="p">:</span>
</span></span><span class="line"><span class="cl"> <span class="nb">print</span><span class="p">(</span><span class="n">r</span><span class="o">.</span><span class="vm">__dict__</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 class="s1">'id'</span><span class="p">:</span> <span class="s1">'user_queries_docs:0e511391dcf346639669bdba70a189c0'</span><span class="p">,</span> <span class="s1">'payload'</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="s1">'user'</span><span class="p">:</span> <span class="s1">'john'</span><span class="p">,</span> <span class="s1">'age'</span><span class="p">:</span> <span class="s1">'18'</span><span class="p">,</span> <span class="s1">'job'</span><span class="p">:</span> <span class="s1">'engineer'</span><span class="p">,</span> <span class="s1">'credit_score'</span><span class="p">:</span> <span class="s1">'high'</span><span class="p">,</span> <span class="s1">'office_location'</span><span class="p">:</span> <span class="s1">'-122.4194,37.7749'</span><span class="p">,</span> <span class="s1">'user_embedding'</span><span class="p">:</span> <span class="s1">'==</span><span class="se">\x00\x00\x00</span><span class="s1">?'</span><span class="p">}</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span><span class="s1">'id'</span><span class="p">:</span> <span class="s1">'user_queries_docs:d204e8e5df90467dbff5b2fb6f800a78'</span><span class="p">,</span> <span class="s1">'payload'</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="s1">'user'</span><span class="p">:</span> <span class="s1">'nancy'</span><span class="p">,</span> <span class="s1">'age'</span><span class="p">:</span> <span class="s1">'94'</span><span class="p">,</span> <span class="s1">'job'</span><span class="p">:</span> <span class="s1">'doctor'</span><span class="p">,</span> <span class="s1">'credit_score'</span><span class="p">:</span> <span class="s1">'high'</span><span class="p">,</span> <span class="s1">'office_location'</span><span class="p">:</span> <span class="s1">'-122.4194,37.7749'</span><span class="p">,</span> <span class="s1">'user_embedding'</span><span class="p">:</span> <span class="s1">'333?=</span><span class="se">\x00\x00\x00</span><span class="s1">?'</span><span class="p">}</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span><span class="s1">'id'</span><span class="p">:</span> <span class="s1">'user_queries_docs:7cf3d6b1a4044966b4f0c5d3725a5e03'</span><span class="p">,</span> <span class="s1">'payload'</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="s1">'user'</span><span class="p">:</span> <span class="s1">'tyler'</span><span class="p">,</span> <span class="s1">'age'</span><span class="p">:</span> <span class="s1">'100'</span><span class="p">,</span> <span class="s1">'job'</span><span class="p">:</span> <span class="s1">'engineer'</span><span class="p">,</span> <span class="s1">'credit_score'</span><span class="p">:</span> <span class="s1">'high'</span><span class="p">,</span> <span class="s1">'office_location'</span><span class="p">:</span> <span class="s1">'-122.0839,37.3861'</span><span class="p">,</span> <span class="s1">'user_embedding'</span><span class="p">:</span> <span class="s1">'=></span><span class="se">\x00\x00\x00</span><span class="s1">?'</span><span class="p">}</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span><span class="s1">'id'</span><span class="p">:</span> <span class="s1">'user_queries_docs:f6581edaaeaf432a85c1d1df8fdf5edc'</span><span class="p">,</span> <span class="s1">'payload'</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="s1">'user'</span><span class="p">:</span> <span class="s1">'tim'</span><span class="p">,</span> <span class="s1">'age'</span><span class="p">:</span> <span class="s1">'12'</span><span class="p">,</span> <span class="s1">'job'</span><span class="p">:</span> <span class="s1">'dermatologist'</span><span class="p">,</span> <span class="s1">'credit_score'</span><span class="p">:</span> <span class="s1">'high'</span><span class="p">,</span> <span class="s1">'office_location'</span><span class="p">:</span> <span class="s1">'-122.0839,37.3861'</span><span class="p">,</span> <span class="s1">'user_embedding'</span><span class="p">:</span> <span class="s1">'>></span><span class="se">\x00\x00\x00</span><span class="s1">?'</span><span class="p">}</span>
</span></span></code></pre>
</div>
<h2 id="inspecting-queries">
Inspecting queries
</h2>
<p>
In this example, you will learn how to inspect the query that is generated by RedisVL. This can be useful for debugging purposes or for understanding how the query is being executed.
</p>
<p>
Consider an example of a query that combines a numeric filter with a tag filter. This will search for users that are between the ages of between 18 and 100, have a high credit score, and sort the results by closest vector distance to the query vector.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">t</span> <span class="o">=</span> <span class="n">Tag</span><span class="p">(</span><span class="s2">"credit_score"</span><span class="p">)</span> <span class="o">==</span> <span class="s2">"high"</span>
</span></span><span class="line"><span class="cl"><span class="n">low</span> <span class="o">=</span> <span class="n">Num</span><span class="p">(</span><span class="s2">"age"</span><span class="p">)</span> <span class="o">>=</span> <span class="mi">18</span>
</span></span><span class="line"><span class="cl"><span class="n">high</span> <span class="o">=</span> <span class="n">Num</span><span class="p">(</span><span class="s2">"age"</span><span class="p">)</span> <span class="o"><=</span> <span class="mi">100</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">combined</span> <span class="o">=</span> <span class="n">t</span> <span class="o">&</span> <span class="n">low</span> <span class="o">&</span> <span class="n">high</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">v</span><span class="o">.</span><span class="n">set_filter</span><span class="p">(</span><span class="n">combined</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Using the str() method, you can see what Redis Query this will emit.</span>
</span></span><span class="line"><span class="cl"><span class="nb">str</span><span class="p">(</span><span class="n">v</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="s1">'((@credit_score:</span><span class="si">{high}</span><span class="s1"> @age:[18 +inf]) @age:[-inf 100])=>[KNN 10 @user_embedding $vector AS vector_distance] RETURN 6 user credit_score age job office_location vector_distance SORTBY vector_distance ASC DIALECT 2 LIMIT 0 10'</span>
</span></span></code></pre>
</div>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="c1"># Cleanup</span>
</span></span><span class="line"><span class="cl"><span class="n">index</span><span class="o">.</span><span class="n">delete</span><span class="p">()</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/redisvl/user-guide/query-filter/"/>
<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/6-2-18-releases/k8s-6-2-18-3/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Redis Enterprise for Kubernetes release notes 6.2.18-3 (Nov 2022)
</h1>
<p class="text-lg -mt-5 mb-10">
Support added for additional distributions, as well as feature improvements and bug fixes.
</p>
<h2 id="overview">
Overview
</h2>
<p>
The Redis Enterprise K8s 6.2.18-3 supports the Redis Enterprise Software release 6.2.18 and includes feature improvements and bug fixes.
</p>
<p>
The key bug fixes, new features, and known limitations are described below.
</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>
If you use NGINX as an ingress controller for Redis Enterprise,
<strong>
do not upgrade
</strong>
to the 6.2.18-3 release. Skip this release and upgrade to version
<a href="/docs/latest/operate/kubernetes/release-notes/6-2-18-releases/">
6.2.18-41
</a>
instead.
</div>
</div>
<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.18-58
</code>
or
<code>
redislabs/redis:6.2.18-58.rhel8-openshift
</code>
(or
<code>
redislabs/redis:6.2.18-58.rhel7-openshift
</code>
if upgrading from RHEL 7)
</li>
<li>
<strong>
Operator
</strong>
:
<code>
redislabs/operator:6.2.18-3
</code>
</li>
<li>
<strong>
Services Rigger
</strong>
:
<code>
redislabs/k8s-controller:6.2.18-3
</code>
or
<code>
redislabs/services-manager:6.2.18-3
</code>
(on the Red Hat registry)
</li>
</ul>
<h2 id="new-features">
New features
</h2>
<ul>
<li>
Support for
<a href="/docs/latest/operate/kubernetes/re-clusters/auto-tiering/">
Auto Tiering
</a>
(RED-78613)
</li>
</ul>
<h2 id="feature-improvements">
Feature improvements
</h2>
<ul>
<li>
<p>
The
<code>
podSecurityPolicyName
</code>
field in
<code>
RedisEnterpriseCluster
</code>
resources is now deprecated for Kubernetes versions 1.24 or earlier, and invalid for 1.25 and later. Customers are advised to switch to using the
<a href="https://kubernetes.io/docs/concepts/security/pod-security-admission/">
<code>
PodSecurityAdmission
</code>
</a>
or alternative methods to enforce pod security (RED-81921).
</p>
</li>
<li>
<p>
Added support for VMware
<a href="https://docs.vmware.com/en/VMware-Tanzu-Kubernetes-Grid/index.html">
Tanzu Kubernetes Grid (TKG)
</a>
, in addition to
<a href="https://docs.vmware.com/en/VMware-Tanzu-Kubernetes-Grid-Integrated-Edition/index.html">
Tanzu Kubernetes Grid Integration Edition (TKGI)
</a>
that was previously and is still supported (RED-65630).
</p>
</li>
<li>
<p>
Added support for PEM encryption through the
<a href="/docs/latest/operate/kubernetes/reference/redis_enterprise_cluster_api/">
Redis Enterprise cluster API
</a>
(RED-78613).
</p>
</li>
<li>
<p>
Hardened security context constraints to align with standards for OpenShift 4.11 (RED-83215).
</p>
</li>
<li>
<p>
Changed log collector default to avoid collection of non-Redis Enterprise logs and items (RED-83216).
</p>
</li>
<li>
<p>
Allowed configuration of the Redis Enterprise cluster (REC) service type (RED-84644).
</p>
</li>
</ul>
<h2 id="bug-fixes">
Bug fixes
</h2>
<ul>
<li>
Allow any ingress class name annotation when using NGINX ingress controller. This is no longer required to be exactly
<code>
nginx
</code>
(RED-79205).
</li>
<li>
Fixed log collector handling of namespace parameter on Windows (RED-83532).
</li>
<li>
Fixed issue with updating credentials on Openshift when accessing the cluster externally with routes (RED-73251, RED-75329).
</li>
</ul>
<h2 id="api-changes">
API changes
</h2>
<p>
The following fields were added to the
<a href="/docs/latest/operate/kubernetes/reference/redis_enterprise_cluster_api/">
Redis Enterprise cluster (REC) API
</a>
:
</p>
<ul>
<li>
Added
<code>
.services.apiService.type
</code>
to allow configuration of the API service type.
</li>
<li>
Made
<code>
.redisOnFlashSpec
</code>
available by default.
</li>
<li>
Made
<code>
.ocspConfiguration
</code>
available by default for configuring OCSP stapling.
</li>
<li>
Made
<code>
.encryptPkeys
</code>
available by default for configuring PEM encryption.
</li>
</ul>
<p>
The following fields were added to the
<a href="/docs/latest/operate/kubernetes/reference/redis_enterprise_database_api/">
Redis Enterprise database (REDB) API
</a>
:
</p>
<ul>
<li>
<code>
.isRoF
</code>
and
<code>
.rofRamSize
</code>
added to support the
<a href="/docs/latest/operate/kubernetes/re-clusters/auto-tiering/">
Auto Tiering feature
</a>
.
</li>
</ul>
<h2 id="compatibility-notes">
Compatibility notes
</h2>
<p>
Below is a table showing supported distributions at the time of this release. See
<a href="/docs/latest/operate/kubernetes/reference/supported_k8s_distributions/">
Supported Kubernetes distributions
</a>
for the current list of supported distributions.
</p>
<table>
<thead>
<tr>
<th style="text-align:left">
<strong>
Kubernetes version
</strong>
</th>
<th style="text-align:center">
1.21
</th>
<th style="text-align:center">
1.22
</th>
<th style="text-align:center">
1.23
</th>
<th style="text-align:center">
1.24
</th>
<th style="text-align:center">
1.25
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
Community Kubernetes
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
supported
</td>
</tr>
<tr>
<td style="text-align:left">
Amazon EKS
</td>
<td style="text-align:center">
deprecated
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
</td>
</tr>
<tr>
<td style="text-align:left">
Azure AKS
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
</td>
</tr>
<tr>
<td style="text-align:left">
Google GKE
</td>
<td style="text-align:center">
deprecated
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
supported*
</td>
</tr>
<tr>
<td style="text-align:left">
Rancher 2.6
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
supported*
</td>
<td style="text-align:center">
</td>
</tr>
<tr>
<td style="text-align:left">
VMware TKG 1.6
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
supported*
</td>
<td style="text-align:center">
supported*
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
</td>
</tr>
<tr>
<td style="text-align:left">
<strong>
OpenShift version
</strong>
</td>
<td style="text-align:center">
<strong>
4.8
</strong>
</td>
<td style="text-align:center">
<strong>
4.9
</strong>
</td>
<td style="text-align:center">
<strong>
4.10
</strong>
</td>
<td style="text-align:center">
<strong>
4.11
</strong>
</td>
<td style="text-align:center">
</td>
</tr>
<tr>
<td style="text-align:left">
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
deprecated
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
supported*
</td>
<td style="text-align:center">
</td>
</tr>
<tr>
<td style="text-align:left">
<strong>
VMware TKGI version
</strong>
</td>
<td style="text-align:center">
<strong>
1.12
</strong>
</td>
<td style="text-align:center">
<strong>
1.13
</strong>
</td>
<td style="text-align:center">
<strong>
1.14
</strong>
</td>
<td style="text-align:center">
<strong>
1.15
</strong>
</td>
<td style="text-align:center">
</td>
</tr>
<tr>
<td style="text-align:left">
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
supported*
</td>
<td style="text-align:center">
</td>
</tr>
</tbody>
</table>
<p>
* Support added in this release
</p>
<h2 id="before-upgrading">
Before upgrading
</h2>
<p>
Be aware the following changes included in this release affect the upgrade process. Please read carefully before upgrading.
</p>
<h3 id="supported-upgrade-paths">
Supported upgrade paths
</h3>
<p>
If you are using operator version 6.2.8-15 or earlier, you cannot upgrade directly to operator versions 6.2.12 through 6.4.2-5. You must upgrade to operator version 6.2.10-45 before you can upgrade to operator versions between 6.2.12 and 6.4.2-5. However, upgrades directly to operator version 6.4.2-6 are supported.
</p>
<h3 id="openshift-versions-6212-or-earlier">
OpenShift versions 6.2.12 or earlier
</h3>
<p>
Due to a change in the SCC, on OpenShift clusters running version 6.2.12 or earlier upgrading to version 6.2.18 or later, where
<code>
node:1
</code>
is
<b>
not
</b>
the master node, the upgrade might get stuck.
</p>
<p>
For more info and steps to prevent this issue, see
<a href="/docs/latest/operate/kubernetes/upgrade/upgrade-redis-cluster/#before-upgrading">
upgrade a Redis Enterprise cluster (REC)
</a>
.
</p>
<p>
Operator version 6.4.2-6 includes a fix for this issue.
</p>
<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.
</p>
<h2 id="known-limitations">
Known limitations
</h2>
<h3 id="large-clusters-1">
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>
<ul>
<li>
<p>
Long cluster names cause routes to be rejected (RED-25871)
</p>
<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>
</li>
<li>
<p>
Cluster CR (REC) errors are not reported after invalid updates (RED-25542)
</p>
<p>
A cluster CR specification error is not reported if two or more invalid CR resources are updated in sequence.
</p>
</li>
<li>
<p>
An unreachable cluster has status running (RED-32805)
</p>
<p>
When a cluster is in an unreachable state, the state is still
<code>
running
</code>
instead of being reported as an error.
</p>
</li>
<li>
<p>
Readiness probe incorrect on failures (RED-39300)
</p>
<p>
STS Readiness probe does not mark a node as "not ready" when running
<code>
rladmin status
</code>
on node failure.
</p>
</li>
<li>
<p>
Internal DNS and Kubernetes DNS may have conflicts (RED-37462)
</p>
<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>
</li>
<li>
<p>
5.4.10 negatively impacts 5.4.6 (RED-37233)
</p>
<p>
Kubernetes-based 5.4.10 deployments seem to negatively impact existing 5.4.6 deployments that share a Kubernetes cluster.
</p>
</li>
<li>
<p>
Node CPU usage is reported instead of pod CPU usage (RED-36884)
</p>
<p>
In Kubernetes, the node CPU usage we report on is the usage of the Kubernetes worker node hosting the REC pod.
</p>
</li>
<li>
<p>
Clusters must be named "rec" in OLM-based deployments (RED-39825)
</p>
<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>
</li>
<li>
<p>
REC clusters fail to start on Kubernetes clusters with unsynchronized clocks (RED-47254)
</p>
<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>
</li>
<li>
<p>
Deleting an OpenShift project with an REC deployed may hang (RED-47192)
</p>
<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>
</li>
<li>
<p>
Hashicorp Vault integration - no support for Gesher (RED-55080)
</p>
<p>
There is no workaround at this time.
</p>
</li>
<li>
<p>
REC might report error states on initial startup (RED-61707)
</p>
<p>
There is no workaround at this time except to ignore the errors.
</p>
</li>
<li>
<p>
PVC size issues when using decimal value in spec (RED-62132)
</p>
<p>
The workaround for this issue is to make sure you use integer values for the PVC size.
</p>
</li>
<li>
<p>
Following old revision of quick start guide causes issues creating an REDB due to unrecognized memory field name (RED-69515)
</p>
<p>
The workaround is to use the newer (current) revision of the quick start document available online.
</p>
</li>
<li>
<p>
<code>
autoUpgrade
</code>
set to true by operator might cause unexpected bdb upgrades when
<code>
redisUpgradePolicy
</code>
is set to true (RED-72351)
</p>
<p>
Contact support if your deployment is impacted.
</p>
</li>
</ul>
<h2 id="security">
Security
</h2>
<p>
For a list of fixes related to CVEs, see the
<a href="/docs/latest/operate/rs/release-notes/rs-6-2-18-releases/rs-6-2-18-58/#security">
Redis Enterprise 6.2.18-58 release notes
</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/kubernetes/release-notes/6-2-18-releases/k8s-6-2-18-3/"/>
<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/zrevrank/.html | <section class="prose w-full py-12">
<h1 class="command-name">
ZREVRANK
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">ZREVRANK key member [WITHSCORE]</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.0.0
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(log(N))
</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 rank of
<code>
member
</code>
in the sorted set stored at
<code>
key
</code>
, with the scores
ordered from high to low.
The rank (or index) is 0-based, which means that the member with the highest
score has rank
<code>
0
</code>
.
</p>
<p>
The optional
<code>
WITHSCORE
</code>
argument supplements the command's reply with the score of the element returned.
</p>
<p>
Use
<a href="/docs/latest/commands/zrank/">
<code>
ZRANK
</code>
</a>
to get the rank of an element with the scores ordered from low to
high.
</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> ZADD myzset 1 "one"
(integer) 1
redis> ZADD myzset 2 "two"
(integer) 1
redis> ZADD myzset 3 "three"
(integer) 1
redis> ZREVRANK myzset "one"
(integer) 2
redis> ZREVRANK myzset "four"
(nil)
redis> ZREVRANK myzset "three" WITHSCORE
1) (integer) 0
2) "3"
redis> ZREVRANK myzset "four" WITHSCORE
(nil)
</pre>
<div class="prompt" style="">
<span>
redis>
</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 key does not exist or the member does not exist in the sorted set.
</li>
<li>
<a href="../../develop/reference/protocol-spec#integers">
Integer reply
</a>
: The rank of the member when
<em>
WITHSCORE
</em>
is not used.
</li>
<li>
<a href="../../develop/reference/protocol-spec#arrays">
Array reply
</a>
: The rank and score of the member when
<em>
WITHSCORE
</em>
is used.
</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 key does not exist or the member does not exist in the sorted set.
</li>
<li>
<a href="../../develop/reference/protocol-spec#integers">
Integer reply
</a>
: The rank of the member when
<em>
WITHSCORE
</em>
is not used.
</li>
<li>
<a href="../../develop/reference/protocol-spec#arrays">
Array reply
</a>
: The rank and score of the member when
<em>
WITHSCORE
</em>
is used.
</li>
</ul>
<br/>
<h2>
History
</h2>
<ul>
<li>
Starting with Redis version 7.2.0: Added the optional
<code>
WITHSCORE
</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/zrevrank/"/>
<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.html | <section class="prose w-full py-12 max-w-none">
<h1>
Redis Cloud
</h1>
<p class="text-lg -mt-5 mb-10">
The fastest way to set up Redis - a fully managed Redis database on major public cloud services.
</p>
<p>
<a href="https://redis.io/cloud/">
Redis Cloud
</a>
is a fully managed database-as-a-service that brings the speed and reliability of Redis to the cloud, offering seamless scalability and high availability for modern applications.
</p>
<p>
With Redis Cloud, you get all of the features of Redis Software, including:
</p>
<ul>
<li>
<a href="/docs/latest/develop/">
Redis
</a>
and
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/">
Redis Stack
</a>
support
</li>
<li>
Linear scalability
</li>
<li>
Instant failover, backups, and recovery
</li>
<li>
Predictable performance
</li>
<li>
24/7 monitoring and support
</li>
</ul>
<p>
<a href="https://redis.io/try-free/">
Try Redis Cloud
</a>
to set up your free 30MB database.
</p>
<h2 id="get-started">
Get started
</h2>
<p>
Use the
<a href="/docs/latest/operate/rc/rc-quickstart/">
Quick start
</a>
to learn how to create your free database.
</p>
<ul>
<li>
<a href="/docs/latest/operate/rc/rc-quickstart/#using-rediscli">
Connect with redis-cli
</a>
</li>
<li>
<a href="/docs/latest/operate/rc/rc-quickstart/#using-redis-client">
Connect with Redis client
</a>
</li>
<li>
<a href="/docs/latest/operate/rc/rc-quickstart/#using-redisinsight">
Connect with Redis Insight
</a>
</li>
</ul>
<h2 id="databases">
Databases
</h2>
<p>
Create and manage
<a href="/docs/latest/operate/rc/databases/">
Redis databases
</a>
in the cloud.
</p>
<ul>
<li>
<a href="/docs/latest/operate/rc/databases/create-database/">
Create database
</a>
</li>
<li>
<a href="/docs/latest/operate/rc/databases/view-edit-database/">
View and edit databases
</a>
</li>
<li>
<a href="/docs/latest/operate/rc/databases/monitor-performance/">
Monitor performance
</a>
</li>
<li>
<a href="/docs/latest/operate/rc/databases/configuration/">
Manage databases
</a>
</li>
<li>
<a href="/docs/latest/commands/">
Redis commands
</a>
&
<a href="/docs/latest/operate/rc/compatibility/">
compatibility
</a>
</li>
</ul>
<h2 id="subscriptions">
Subscriptions
</h2>
<p>
Learn about the
<a href="/docs/latest/operate/rc/subscriptions/">
types of subscriptions
</a>
.
</p>
<ul>
<li>
<a href="/docs/latest/operate/rc/subscriptions/view-essentials-subscription/">
View and upgrade Essentials plan
</a>
</li>
<li>
<a href="/docs/latest/operate/rc/subscriptions/view-essentials-subscription/essentials-plan-details/">
Essentials plans
</a>
</li>
<li>
<a href="/docs/latest/operate/rc/subscriptions/view-pro-subscription/">
View and edit Pro plan
</a>
</li>
</ul>
<h2 id="accounts--settings">
Accounts & settings
</h2>
<p>
Manage Redis Cloud
<a href="/docs/latest/operate/rc/accounts/">
accounts and settings
</a>
.
</p>
<ul>
<li>
<a href="/docs/latest/operate/rc/billing-and-payments/">
Billing and payments
</a>
</li>
<li>
<a href="/docs/latest/operate/rc/cloud-integrations/">
Manage marketplace integrations
</a>
</li>
</ul>
<h2 id="security">
Security
</h2>
<p>
Manage
<a href="/docs/latest/operate/rc/security/">
secure connections
</a>
to cloud databases.
</p>
<ul>
<li>
<a href="/docs/latest/operate/rc/security/access-control/access-management/">
Access management
</a>
for Redis Cloud console security and account management
</li>
<li>
<a href="/docs/latest/operate/rc/security/database-security/">
Cloud database security
</a>
</li>
<li>
<a href="/docs/latest/operate/rc/security/access-control/multi-factor-authentication/">
Multi-factor authentication
</a>
</li>
<li>
<a href="/docs/latest/operate/rc/security/access-control/saml-sso/">
Single sign-on
</a>
and
<a href="/docs/latest/operate/rc/security/access-control/social-login/">
social login
</a>
</li>
<li>
<a href="/docs/latest/operate/rc/security/access-control/data-access-control/">
Data access control
</a>
</li>
</ul>
<h2 id="rest-api">
REST API
</h2>
<p>
Use the
<a href="/docs/latest/operate/rc/api/">
REST API
</a>
to manage the database.
</p>
<ul>
<li>
<a href="/docs/latest/operate/rc/api/get-started/">
Get started with the REST API
</a>
</li>
<li>
REST API
<a href="https://api.redislabs.com/v1/swagger-ui.html">
reference
</a>
&
<a href="/docs/latest/operate/rc/api/examples/">
examples
</a>
</li>
</ul>
<h2 id="related-info">
Related info
</h2>
<ul>
<li>
<a href="/docs/latest/operate/rs/">
Redis Enterprise Software
</a>
</li>
<li>
<a href="/docs/latest/develop/">
Develop with Redis
</a>
</li>
<li>
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/">
Redis Stack
</a>
</li>
<li>
<a href="/docs/latest/glossary/">
Glossary
</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/"/>
<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-6-2-18-releases/rs-6-2-18-70/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Redis Enterprise Software release notes 6.2.18-70 (January 2023)
</h1>
<p class="text-lg -mt-5 mb-10">
New script to generate new self-signed certificates for renewal. Improved logs. Deactivate alert_mgr using rladmin.
</p>
<p>
This is a maintenance release for β
<a href="https://redis.com/redis-enterprise-software/download-center/software/">
βRedis Enterprise Software version 6.2.18
</a>
.
</p>
<p>
The following table shows the MD5 checksums for the available packages:
</p>
<table>
<thead>
<tr>
<th style="text-align:left">
Package
</th>
<th style="text-align:left">
MD5 checksum (6.2.18-70 January release)
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
Ubuntu 16
</td>
<td style="text-align:left">
<code>
69d2d2c71232adb15cebf29308ac54da
</code>
</td>
</tr>
<tr>
<td style="text-align:left">
Ubuntu 18
</td>
<td style="text-align:left">
<code>
22e0637107a32ccb96a704abe9650adf
</code>
</td>
</tr>
<tr>
<td style="text-align:left">
RedHat Enterprise Linux (RHEL) 7
<br/>
Oracle Enterprise Linux (OL) 7
</td>
<td style="text-align:left">
<code>
e14fcf6973418602f2b64a55a0bc8374
</code>
</td>
</tr>
<tr>
<td style="text-align:left">
RedHat Enterprise Linux (RHEL) 8
<br/>
Oracle Enterprise Linux (OL) 8
<br/>
Rocky Enterprise Linux
</td>
<td style="text-align:left">
<code>
f61d0d8f0bb5ad90a470482d6575eb27
</code>
</td>
</tr>
</tbody>
</table>
<h2 id="new-features-and-enhancements">
New features and enhancements
</h2>
<ul>
<li>
Added a new script to generate new self-signed certificates for renewal. For details, see
<a href="/docs/latest/operate/rs/security/certificates/">
Certificates
</a>
</li>
<li>
Added
<code>
rpm -q
</code>
command output to the logs (RS82673)
</li>
<li>
Added logs for server operations:
<code>
start
</code>
,
<code>
stop
</code>
,
<code>
restart
</code>
(RS87775)
</li>
<li>
Added
<code>
alert_mgr
</code>
to the
<a href="/docs/latest/operate/rs/clusters/optimize/turn-off-services/">
services you can deactivate with
<code>
rladmin
</code>
</a>
(RS89572)
</li>
</ul>
<h2 id="resolved-issues">
Resolved issues
</h2>
<ul>
<li>
RS61062 - Remove leading colon added to
<code>
PATH
</code>
variable
</li>
</ul>
<h2 id="known-upgrade-limitations">
Known upgrade limitations
</h2>
<p>
Before you upgrade a cluster that hosts Active-Active databases with modules to v6.2.18, perform the following steps:
</p>
<ol>
<li>
<p>
Use
<code>
crdb-cli
</code>
to verify that the modules (
<code>
modules
</code>
) and their versions (in
<code>
module_list
</code>
) are as they appear in the database configuration and in the default database configuration:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">crdb-cli crdb get --crdb-guid <crdb-guid>
</span></span></code></pre>
</div>
</li>
<li>
<p>
From the admin console's
<strong>
redis modules
</strong>
tab, validate that these modules with their specific versions are loaded to the cluster.
</p>
</li>
<li>
<p>
If one or more of the modules/versions are missing or if you need help,
<a href="https://redis.com/company/support/">
contact Redis support
</a>
before taking additional steps.
</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/release-notes/rs-6-2-18-releases/rs-6-2-18-70/"/>
<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/redisbloom/redisbloom-2.6-release-notes.html | <section class="prose w-full py-12 max-w-none">
<h1>
RedisBloom 2.6 release notes
</h1>
<p class="text-lg -mt-5 mb-10">
RESP3 support. Bug fixes.
</p>
<h2 id="requirements">
Requirements
</h2>
<p>
RedisBloom v2.6.13 requires:
</p>
<ul>
<li>
Minimum Redis compatibility version (database): 7.2
</li>
<li>
Minimum Redis Enterprise Software version (cluster): 7.2.4
</li>
</ul>
<h2 id="v2613-july-2024">
v2.6.13 (July 2024)
</h2>
<p>
This is a maintenance release for RedisBloom 2.6
</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/RedisBloom/RedisBloom/pull/720">
#720
</a>
<code>
BF
</code>
crashes on high error rate (MOD-6268)
</li>
<li>
<a href="https://github.com/RedisBloom/RedisBloom/pull/773">
#773
</a>
<code>
CMS.MERGE
</code>
: reply with an error on overflow and underflow (MOD-6962)
</li>
</ul>
</li>
</ul>
<h2 id="v2612-march-2024">
v2.6.12 (March 2024)
</h2>
<p>
This is a maintenance release for RedisBloom 2.6.
</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/RedisBloom/RedisBloom/issues/753">
#753
</a>
Potential crash on
<code>
CMS.MERGE
</code>
when using invalid arguments
</li>
</ul>
</li>
</ul>
<h2 id="v2611-january-2024">
v2.6.11 (January 2024)
</h2>
<p>
This is a maintenance release for RedisBloom 2.6.
</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/RedisBloom/RedisBloom/pull/727">
#727
</a>
Additional fixes for potential crash on
<code>
CF.LOADCHUNK
</code>
(MOD-6344)
</li>
</ul>
</li>
</ul>
<h2 id="v2610-january-2024">
v2.6.10 (January 2024)
</h2>
<p>
This is a maintenance release for RedisBloom 2.6.
</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/RedisBloom/RedisBloom/pull/735">
#735
</a>
Potential crash on
<code>
CF.RESERVE
</code>
(MOD-6343)
</li>
<li>
<a href="https://github.com/RedisBloom/RedisBloom/pull/727">
#727
</a>
Potential crash on
<code>
CF.LOADCHUNK
</code>
(MOD-6344)
</li>
</ul>
</li>
</ul>
<h2 id="v269-december-2023">
v2.6.9 (December 2023)
</h2>
<p>
This is a maintenance release for RedisBloom 2.6.
</p>
<p>
Update urgency:
<code>
LOW
</code>
: No need to upgrade unless there are new features you want to use.
</p>
<p>
Details:
</p>
<ul>
<li>
<p>
Bug fixes:
</p>
<ul>
<li>
<a href="https://github.com/RedisBloom/RedisBloom/pull/707">
#707
</a>
Top-K:
<code>
TOPK.ADD
</code>
and
<code>
TOPK.QUERY
</code>
crash when an item name is an empty string (RED-114676)
</li>
</ul>
</li>
</ul>
<h2 id="v268-october-2023">
v2.6.8 (October 2023)
</h2>
<p>
This is a maintenance release for RedisBloom 2.6.
</p>
<p>
Update urgency:
<code>
LOW
</code>
: No need to upgrade unless there are new features you want to use.
</p>
<p>
Details:
</p>
<ul>
<li>
<p>
Improvements:
</p>
<ul>
<li>
<a href="https://github.com/RedisBloom/RedisBloom/pull/684">
#684
</a>
,
<a href="https://github.com/RedisBloom/RedisBloom/pull/685">
#685
</a>
Added support for CBL-Mariner 2
</li>
<li>
<a href="https://github.com/RedisBloom/RedisBloom/pull/677">
#677
</a>
,
<a href="https://github.com/RedisBloom/RedisBloom/pull/678">
#678
</a>
Added support for Rocky Linux 9 and RHEL9
</li>
</ul>
</li>
</ul>
<h2 id="v26-ga-v263-july-2023">
v2.6 GA (v2.6.3) (July 2023)
</h2>
<p>
This is the General Availability release of RedisBloom 2.6.
</p>
<h3 id="headlines">
Headlines
</h3>
<p>
RedisBloom 2.6 introduces support for RESP3 and bug fixes.
</p>
<h3 id="details">
Details
</h3>
<p>
Improvements:
</p>
<ul>
<li>
<a href="https://github.com/RedisBloom/RedisBloom/pull/664">
#664
</a>
<code>
TOPK.ADD
</code>
,
<code>
TOPK.INCRBY
</code>
, and
<code>
TOPK.LIST
</code>
reply with blob string instead of simple string.
</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>
<p>
The version inside Redis will be 2.6.3 in semantic versioning. Since the version of a module in Redis is numeric, we could not add a GA flag.
</p>
</li>
<li>
<p>
Minimal Redis version: 7.2
</p>
</li>
</ul>
</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/redisbloom/redisbloom-2.6-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/crdb-cli/crdb/create/.html | <section class="prose w-full py-12 max-w-none">
<h1>
crdb-cli crdb create
</h1>
<p class="text-lg -mt-5 mb-10">
Creates an Active-Active database.
</p>
<p>
Creates 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 create --name <name>
</span></span><span class="line"><span class="cl"> --memory-size <maximum_memory>
</span></span><span class="line"><span class="cl"> --instance <span class="nv">fqdn</span><span class="o">=</span><cluster_fqdn>,username<span class="o">=</span><username>,password<span class="o">=</span><password><span class="o">[</span>,url<span class="o">=</span><url>,replication_endpoint<span class="o">=</span><endpoint><span class="o">]</span>
</span></span><span class="line"><span class="cl"> --instance <span class="nv">fqdn</span><span class="o">=</span><cluster_fqdn>,username<span class="o">=</span><username>,password<span class="o">=</span><password><span class="o">[</span>,url<span class="o">=</span><url>,replication_endpoint<span class="o">=</span><endpoint><span class="o">]</span>
</span></span><span class="line"><span class="cl"> <span class="o">[</span>--port <port_number><span class="o">]</span>
</span></span><span class="line"><span class="cl"> <span class="o">[</span>--no-wait<span class="o">]</span>
</span></span><span class="line"><span class="cl"> <span class="o">[</span>--default-db-config <configuration><span class="o">]</span>
</span></span><span class="line"><span class="cl"> <span class="o">[</span>--default-db-config-file <filename><span class="o">]</span>
</span></span><span class="line"><span class="cl"> <span class="o">[</span>--compression <0-6><span class="o">]</span>
</span></span><span class="line"><span class="cl"> <span class="o">[</span>--causal-consistency <span class="o">{</span> <span class="nb">true</span> <span class="p">|</span> <span class="nb">false</span> <span class="o">}</span> <span class="o">]</span>
</span></span><span class="line"><span class="cl"> <span class="o">[</span>--password <password><span class="o">]</span>
</span></span><span class="line"><span class="cl"> <span class="o">[</span>--replication <span class="o">{</span> <span class="nb">true</span> <span class="p">|</span> <span class="nb">false</span> <span class="o">}</span> <span class="o">]</span>
</span></span><span class="line"><span class="cl"> <span class="o">[</span>--encryption <span class="o">{</span> <span class="nb">true</span> <span class="p">|</span> <span class="nb">false</span> <span class="o">}</span> <span class="o">]</span>
</span></span><span class="line"><span class="cl"> <span class="o">[</span>--sharding <span class="o">{</span> <span class="nb">false</span> <span class="p">|</span> <span class="nb">true</span> <span class="o">}</span> <span class="o">]</span>
</span></span><span class="line"><span class="cl"> <span class="o">[</span>--shards-count <number_of_shards><span class="o">]</span>
</span></span><span class="line"><span class="cl"> <span class="o">[</span>--shard-key-regex <regex_rule><span class="o">]</span>
</span></span><span class="line"><span class="cl"> <span class="o">[</span>--oss-cluster <span class="o">{</span> <span class="nb">true</span> <span class="p">|</span> <span class="nb">false</span> <span class="o">}</span> <span class="o">]</span>
</span></span><span class="line"><span class="cl"> <span class="o">[</span>--bigstore <span class="o">{</span> <span class="nb">true</span> <span class="p">|</span> <span class="nb">false</span> <span class="o">}]</span>
</span></span><span class="line"><span class="cl"> <span class="o">[</span>--bigstore-ram-size <maximum_memory><span class="o">]</span>
</span></span><span class="line"><span class="cl"> <span class="o">[</span>--with-module <span class="nv">name</span><span class="o">=</span><module_name>,version<span class="o">=</span><module_version>,args<span class="o">=</span><module_args><span class="o">]</span>
</span></span></code></pre>
</div>
<h3 id="prerequisites">
Prerequisites
</h3>
<p>
Before you create an Active-Active database, you must have:
</p>
<ul>
<li>
At least two participating clusters
</li>
<li>
<a href="/docs/latest/operate/rs/networking/port-configurations/">
Network connectivity
</a>
between the participating clusters
</li>
</ul>
<h3 id="parameters">
Parameters
</h3>
<table>
<thead>
<tr>
<th>
ParameterΒ &Β options(s)
</th>
<th>
Value
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
name <CRDB_name>
</td>
<td>
string
</td>
<td>
Name of the Active-Active database (required)
</td>
</tr>
<tr>
<td>
memory-size <maximum_memory>
</td>
<td>
size in bytes, kilobytes (KB), or gigabytes (GB)
</td>
<td>
Maximum database memory (required)
</td>
</tr>
<tr>
<td>
instance
<br/>
fqdn=<cluster_fqdn>,
<br/>
username=<username>,
<br/>
password=<password>
</td>
<td>
strings
</td>
<td>
The connection information for the participating clusters (required for each participating cluster)
</td>
</tr>
<tr>
<td>
port <port_number>
</td>
<td>
integer
</td>
<td>
TCP port for the Active-Active database on all participating clusters
</td>
</tr>
<tr>
<td>
default-db-config <configuration>
</td>
<td>
string
</td>
<td>
Default database configuration options
</td>
</tr>
<tr>
<td>
default-db-config-file <filename>
</td>
<td>
filepath
</td>
<td>
Default database configuration options from a file
</td>
</tr>
<tr>
<td>
no-wait
</td>
<td>
</td>
<td>
Prevents
<code>
crdb-cli
</code>
from running another command before this command finishes
</td>
</tr>
<tr>
<td>
compression
</td>
<td>
0-6
</td>
<td>
The level of data compression:
<br/>
<br/>
0 = No compression
<br/>
<br/>
6 = High compression and resource load (Default: 3)
</td>
</tr>
<tr>
<td>
causal-consistency
</td>
<td>
true
<br/>
false (
<em>
default
</em>
)
</td>
<td>
<a href="/docs/latest/operate/rs/databases/active-active/causal-consistency/">
Causal consistency
</a>
applies updates to all instances in the order they were received
</td>
</tr>
<tr>
<td>
password <password>
</td>
<td>
string
</td>
<td>
Password for access to the database
</td>
</tr>
<tr>
<td>
replication
</td>
<td>
true
<br/>
false (
<em>
default
</em>
)
</td>
<td>
Activates or deactivates
<a href="/docs/latest/operate/rs/databases/durability-ha/replication/">
database replication
</a>
where every master shard replicates to a replica shard
</td>
</tr>
<tr>
<td>
encryption
</td>
<td>
true
<br/>
false (
<em>
default
</em>
)
</td>
<td>
Activates or deactivates encryption
</td>
</tr>
<tr>
<td>
sharding
</td>
<td>
true
<br/>
false (
<em>
default
</em>
)
</td>
<td>
Activates or deactivates sharding (also known as
<a href="/docs/latest/operate/rs/databases/durability-ha/replication/">
database clustering
</a>
). Cannot be updated after the database is created
</td>
</tr>
<tr>
<td>
shards-count <number_of_shards>
</td>
<td>
integer
</td>
<td>
If sharding is enabled, this specifies the number of Redis shards for each database instance
</td>
</tr>
<tr>
<td>
oss-cluster
</td>
<td>
true
<br/>
false (
<em>
default
</em>
)
</td>
<td>
Activates
<a href="/docs/latest/operate/rs/clusters/optimize/oss-cluster-api/">
OSS cluster API
</a>
</td>
</tr>
<tr>
<td>
shard-key-regex <regex_rule>
</td>
<td>
string
</td>
<td>
If clustering is enabled, this defines a regex rule (also known as a
<a href="/docs/latest/operate/rs/databases/durability-ha/clustering/#custom-hashing-policy">
hashing policy
</a>
) that determines which keys are located in each shard (defaults to
<code>
{u'regex': u'.*\\{(?<tag>.*)\\}.*'}, {u'regex': u'(?<tag>.*)'}
</code>
)
</td>
</tr>
<tr>
<td>
bigstore
</td>
<td>
true
<br/>
<br/>
false (
<em>
default
</em>
)
</td>
<td>
If true, the database uses Auto Tiering to add flash memory to the database
</td>
</tr>
<tr>
<td>
bigstore-ram-size <size>
</td>
<td>
size in bytes, kilobytes (KB), or gigabytes (GB)
</td>
<td>
Maximum RAM limit for databases with Auto Tiering enabled
</td>
</tr>
<tr>
<td>
with-module
<br/>
name=<module_name>,
<br/>
version=<module_version>,
<br/>
args=<module_args>
</td>
<td>
strings
</td>
<td>
Creates a database with a specific module
</td>
</tr>
<tr>
<td>
eviction-policy
</td>
<td>
noeviction (
<em>
default
</em>
)
<br/>
allkeys-lru
<br/>
allkeys-lfu
<br/>
allkeys-random
<br/>
volatile-lru
<br/>
volatile-lfu
<br/>
volatile-random
<br/>
volatile-ttl
</td>
<td>
Sets
<a href="/docs/latest/operate/rs/databases/memory-performance/eviction-policy/">
eviction policy
</a>
</td>
</tr>
<tr>
<td>
proxy-policy
</td>
<td>
all-nodes
<br/>
all-master-shards
<br/>
single
</td>
<td>
Sets proxy policy
</td>
</tr>
</tbody>
</table>
<h3 id="returns">
Returns
</h3>
<p>
Returns the task ID of the task that is creating the database.
</p>
<p>
If
<code>
--no-wait
</code>
is specified, the command exits. Otherwise, it will wait for the database to be created and then return the CRDB GUID.
</p>
<h3 id="examples">
Examples
</h3>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ crdb-cli crdb create --name database1 --memory-size 1GB --port <span class="m">12000</span> <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>cluster1.redis.local,username<span class="o">=</span>[email protected],password<span class="o">=</span>admin <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>cluster2.redis.local,username<span class="o">=</span>[email protected],password<span class="o">=</span>admin
</span></span><span class="line"><span class="cl">Task 633aaea3-97ee-4bcb-af39-a9cb25d7d4da created
</span></span><span class="line"><span class="cl"> ---> Status changed: queued -> started
</span></span><span class="line"><span class="cl"> ---> CRDB GUID Assigned: crdb:d84f6fe4-5bb7-49d2-a188-8900e09c6f66
</span></span><span class="line"><span class="cl"> ---> Status changed: started -> finished
</span></span></code></pre>
</div>
<p>
To create an Active-Active database with two shards in each instance and with encrypted traffic between the clusters:
</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 mycrdb --memory-size 100mb --port <span class="m">12000</span> --instance <span class="nv">fqdn</span><span class="o">=</span>cluster1.redis.local,username<span class="o">=</span>[email protected],password<span class="o">=</span>admin --instance <span class="nv">fqdn</span><span class="o">=</span>cluster2.redis.local,username<span class="o">=</span>[email protected],password<span class="o">=</span>admin --shards-count <span class="m">2</span> --encryption <span class="nb">true</span>
</span></span></code></pre>
</div>
<p>
To create an Active-Active database with two shards and with RediSearch 2.0.6 module:
</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 mycrdb --memory-size 100mb --port <span class="m">12000</span> --instance <span class="nv">fqdn</span><span class="o">=</span>cluster1.redis.local,username<span class="o">=</span>[email protected],password<span class="o">=</span>admin --instance <span class="nv">fqdn</span><span class="o">=</span>cluster2.redis.local,username<span class="o">=</span>[email protected],password<span class="o">=</span>admin --shards-count <span class="m">2</span> --with-module <span class="nv">name</span><span class="o">=</span>search,version<span class="o">=</span><span class="s2">"2.0.6"</span>,args<span class="o">=</span><span class="s2">"PARTITIONS AUTO"</span>
</span></span></code></pre>
</div>
<p>
To create an Active-Active database with two shards and with encrypted traffic between the clusters:
</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 mycrdb --memory-size 100mb --port <span class="m">12000</span> --instance <span class="nv">fqdn</span><span class="o">=</span>cluster1.redis.local,username<span class="o">=</span>[email protected],password<span class="o">=</span>admin --instance <span class="nv">fqdn</span><span class="o">=</span>cluster2.redis.local,username<span class="o">=</span>[email protected],password<span class="o">=</span>admin --encryption <span class="nb">true</span> --shards-count <span class="m">2</span>
</span></span></code></pre>
</div>
<p>
To create an Active-Active database with 1 shard in each instance and not wait for the response:
</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 mycrdb --memory-size 100mb --port <span class="m">12000</span> --instance <span class="nv">fqdn</span><span class="o">=</span>cluster1.redis.local,username<span class="o">=</span>[email protected],password<span class="o">=</span>admin --instance <span class="nv">fqdn</span><span class="o">=</span>cluster2.redis.local,username<span class="o">=</span>[email protected],password<span class="o">=</span>admin --no-wait
</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/crdb-cli/crdb/create/"/>
<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/sunion/.html | <section class="prose w-full py-12">
<h1 class="command-name">
SUNION
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">SUNION key [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 total number of elements in all given sets.
</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 the members of the set resulting from the union of all the given sets.
</p>
<p>
For example:
</p>
<pre tabindex="0"><code>key1 = {a,b,c,d}
key2 = {c}
key3 = {a,c,e}
SUNION key1 key2 key3 = {a,b,c,d,e}
</code></pre>
<p>
Keys that do not exist are considered to be empty sets.
</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> SADD key1 "a"
(integer) 1
redis> SADD key1 "b"
(integer) 1
redis> SADD key1 "c"
(integer) 1
redis> SADD key2 "c"
(integer) 1
redis> SADD key2 "d"
(integer) 1
redis> SADD key2 "e"
(integer) 1
redis> SUNION key1 key2
1) "a"
2) "b"
3) "c"
4) "d"
5) "e"
</pre>
<div class="prompt" style="">
<span>
redis>
</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 list with members of the resulting set.
<h2 id="resp3-reply">
RESP3 Reply
</h2>
<a href="../../develop/reference/protocol-spec#sets">
Set reply
</a>
: a set with the members of the resulting 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/sunion/"/>
<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/management/scaling/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Scale with Redis Cluster
</h1>
<p class="text-lg -mt-5 mb-10">
Horizontal scaling with Redis Cluster
</p>
<p>
Redis scales horizontally with a deployment topology called Redis Cluster.
This topic will teach you how to set up, test, and operate Redis Cluster in production.
You will learn about the availability and consistency characteristics of Redis Cluster from the end user's point of view.
</p>
<p>
If you plan to run a production Redis Cluster deployment or want to understand better how Redis Cluster works internally, consult the
<a href="/docs/latest/operate/oss_and_stack/reference/cluster-spec/">
Redis Cluster specification
</a>
. To learn how Redis Enterprise handles scaling, see
<a href="https://redis.com/redis-enterprise/technology/linear-scaling-redis-enterprise/">
Linear Scaling with Redis Enterprise
</a>
.
</p>
<h2 id="redis-cluster-101">
Redis Cluster 101
</h2>
<p>
Redis Cluster provides a way to run a Redis installation where data is automatically sharded across multiple Redis nodes.
Redis Cluster also provides some degree of availability during partitionsβin practical terms, the ability to continue operations when some nodes fail or are unable to communicate.
However, the cluster will become unavailable in the event of larger failures (for example, when the majority of masters are unavailable).
</p>
<p>
So, with Redis Cluster, you get the ability to:
</p>
<ul>
<li>
Automatically split your dataset among multiple nodes.
</li>
<li>
Continue operations when a subset of the nodes are experiencing failures or are unable to communicate with the rest of the cluster.
</li>
</ul>
<h4 id="redis-cluster-tcp-ports">
Redis Cluster TCP ports
</h4>
<p>
Every Redis Cluster node requires two open TCP connections: a Redis TCP port used to serve clients, e.g., 6379, and second port known as the
<em>
cluster bus port
</em>
.
By default, the cluster bus port is set by adding 10000 to the data port (e.g., 16379); however, you can override this in the
<code>
cluster-port
</code>
configuration.
</p>
<p>
Cluster bus is a node-to-node communication channel that uses a binary protocol, which is more suited to exchanging information between nodes due to
little bandwidth and processing time.
Nodes use the cluster bus for failure detection, configuration updates, failover authorization, and so forth.
Clients should never try to communicate with the cluster bus port, but rather use the Redis command port.
However, make sure you open both ports in your firewall, otherwise Redis cluster nodes won't be able to communicate.
</p>
<p>
For a Redis Cluster to work properly you need, for each node:
</p>
<ol>
<li>
The client communication port (usually 6379) used to communicate with clients and be open to all the clients that need to reach the cluster, plus all the other cluster nodes that use the client port for key migrations.
</li>
<li>
The cluster bus port must be reachable from all the other cluster nodes.
</li>
</ol>
<p>
If you don't open both TCP ports, your cluster will not work as expected.
</p>
<h4 id="redis-cluster-and-docker">
Redis Cluster and Docker
</h4>
<p>
Currently, Redis Cluster does not support NATted environments and in general
environments where IP addresses or TCP ports are remapped.
</p>
<p>
Docker uses a technique called
<em>
port mapping
</em>
: programs running inside Docker containers may be exposed with a different port compared to the one the program believes to be using.
This is useful for running multiple containers using the same ports, at the same time, in the same server.
</p>
<p>
To make Docker compatible with Redis Cluster, you need to use Docker's
<em>
host networking mode
</em>
.
Please see the
<code>
--net=host
</code>
option in the
<a href="https://docs.docker.com/engine/userguide/networking/dockernetworks/">
Docker documentation
</a>
for more information.
</p>
<h4 id="redis-cluster-data-sharding">
Redis Cluster data sharding
</h4>
<p>
Redis Cluster does not use consistent hashing, but a different form of sharding
where every key is conceptually part of what we call a
<strong>
hash slot
</strong>
.
</p>
<p>
There are 16384 hash slots in Redis Cluster, and to compute the hash
slot for a given key, we simply take the CRC16 of the key modulo
16384.
</p>
<p>
Every node in a Redis Cluster is responsible for a subset of the hash slots,
so, for example, you may have a cluster with 3 nodes, where:
</p>
<ul>
<li>
Node A contains hash slots from 0 to 5500.
</li>
<li>
Node B contains hash slots from 5501 to 11000.
</li>
<li>
Node C contains hash slots from 11001 to 16383.
</li>
</ul>
<p>
This makes it easy to add and remove cluster nodes. For example, if
I want to add a new node D, I need to move some hash slots from nodes A, B, C
to D. Similarly, if I want to remove node A from the cluster, I can just
move the hash slots served by A to B and C. Once node A is empty,
I can remove it from the cluster completely.
</p>
<p>
Moving hash slots from a node to another does not require stopping
any operations; therefore, adding and removing nodes, or changing the percentage of hash slots held by a node, requires no downtime.
</p>
<p>
Redis Cluster supports multiple key operations as long as all of the keys involved in a single command execution (or whole transaction, or Lua script
execution) belong to the same hash slot. The user can force multiple keys
to be part of the same hash slot by using a feature called
<em>
hash tags
</em>
.
</p>
<p>
Hash tags are documented in the Redis Cluster specification, but the gist is
that if there is a substring between {} brackets in a key, only what is
inside the string is hashed. For example, the keys
<code>
user:{123}:profile
</code>
and
<code>
user:{123}:account
</code>
are guaranteed to be in the same hash slot because they share the same hash tag. As a result, you can operate on these two keys in the same multi-key operation.
</p>
<h4 id="redis-cluster-master-replica-model">
Redis Cluster master-replica model
</h4>
<p>
To remain available when a subset of master nodes are failing or are
not able to communicate with the majority of nodes, Redis Cluster uses a
master-replica model where every hash slot has from 1 (the master itself) to N
replicas (N-1 additional replica nodes).
</p>
<p>
In our example cluster with nodes A, B, C, if node B fails the cluster is not
able to continue, since we no longer have a way to serve hash slots in the
range 5501-11000.
</p>
<p>
However, when the cluster is created (or at a later time), we add a replica
node to every master, so that the final cluster is composed of A, B, C
that are master nodes, and A1, B1, C1 that are replica nodes.
This way, the system can continue if node B fails.
</p>
<p>
Node B1 replicates B, and B fails, the cluster will promote node B1 as the new
master and will continue to operate correctly.
</p>
<p>
However, note that if nodes B and B1 fail at the same time, Redis Cluster will not be able to continue to operate.
</p>
<h4 id="redis-cluster-consistency-guarantees">
Redis Cluster consistency guarantees
</h4>
<p>
Redis Cluster does not guarantee
<strong>
strong consistency
</strong>
. In practical
terms this means that under certain conditions it is possible that Redis
Cluster will lose writes that were acknowledged by the system to the client.
</p>
<p>
The first reason why Redis Cluster can lose writes is because it uses
asynchronous replication. This means that during writes the following
happens:
</p>
<ul>
<li>
Your client writes to the master B.
</li>
<li>
The master B replies OK to your client.
</li>
<li>
The master B propagates the write to its replicas B1, B2 and B3.
</li>
</ul>
<p>
As you can see, B does not wait for an acknowledgement from B1, B2, B3 before
replying to the client, since this would be a prohibitive latency penalty
for Redis, so if your client writes something, B acknowledges the write,
but crashes before being able to send the write to its replicas, one of the
replicas (that did not receive the write) can be promoted to master, losing
the write forever.
</p>
<p>
This is very similar to what happens with most databases that are
configured to flush data to disk every second, so it is a scenario you
are already able to reason about because of past experiences with traditional
database systems not involving distributed systems. Similarly you can
improve consistency by forcing the database to flush data to disk before
replying to the client, but this usually results in prohibitively low
performance. That would be the equivalent of synchronous replication in
the case of Redis Cluster.
</p>
<p>
Basically, there is a trade-off to be made between performance and consistency.
</p>
<p>
Redis Cluster has support for synchronous writes when absolutely needed,
implemented via the
<a href="/commands/wait">
<code>
WAIT
</code>
</a>
command. This makes losing writes a lot less
likely. However, note that Redis Cluster does not implement strong consistency
even when synchronous replication is used: it is always possible, under more
complex failure scenarios, that a replica that was not able to receive the write
will be elected as master.
</p>
<p>
There is another notable scenario where Redis Cluster will lose writes, that
happens during a network partition where a client is isolated with a minority
of instances including at least a master.
</p>
<p>
Take as an example our 6 nodes cluster composed of A, B, C, A1, B1, C1,
with 3 masters and 3 replicas. There is also a client, that we will call Z1.
</p>
<p>
After a partition occurs, it is possible that in one side of the
partition we have A, C, A1, B1, C1, and in the other side we have B and Z1.
</p>
<p>
Z1 is still able to write to B, which will accept its writes. If the
partition heals in a very short time, the cluster will continue normally.
However, if the partition lasts enough time for B1 to be promoted to master
on the majority side of the partition, the writes that Z1 has sent to B
in the meantime will be lost.
</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 is a
<strong>
maximum window
</strong>
to the amount of writes Z1 will be able
to send to B: if enough time has elapsed for the majority side of the
partition to elect a replica as master, every master node in the minority
side will have stopped accepting writes.
</div>
</div>
<p>
This amount of time is a very important configuration directive of Redis
Cluster, and is called the
<strong>
node timeout
</strong>
.
</p>
<p>
After node timeout has elapsed, a master node is considered to be failing,
and can be replaced by one of its replicas.
Similarly, after node timeout has elapsed without a master node to be able
to sense the majority of the other master nodes, it enters an error state
and stops accepting writes.
</p>
<h2 id="redis-cluster-configuration-parameters">
Redis Cluster configuration parameters
</h2>
<p>
We are about to create an example cluster deployment.
Before we continue, let's introduce the configuration parameters that Redis Cluster introduces
in the
<code>
redis.conf
</code>
file.
</p>
<ul>
<li>
<strong>
cluster-enabled
<code>
<yes/no>
</code>
</strong>
: If yes, enables Redis Cluster support in a specific Redis instance. Otherwise the instance starts as a standalone instance as usual.
</li>
<li>
<strong>
cluster-config-file
<code>
<filename>
</code>
</strong>
: Note that despite the name of this option, this is not a user editable configuration file, but the file where a Redis Cluster node automatically persists the cluster configuration (the state, basically) every time there is a change, in order to be able to re-read it at startup. The file lists things like the other nodes in the cluster, their state, persistent variables, and so forth. Often this file is rewritten and flushed on disk as a result of some message reception.
</li>
<li>
<strong>
cluster-node-timeout
<code>
<milliseconds>
</code>
</strong>
: The maximum amount of time a Redis Cluster node can be unavailable, without it being considered as failing. If a master node is not reachable for more than the specified amount of time, it will be failed over by its replicas. This parameter controls other important things in Redis Cluster. Notably, every node that can't reach the majority of master nodes for the specified amount of time, will stop accepting queries.
</li>
<li>
<strong>
cluster-slave-validity-factor
<code>
<factor>
</code>
</strong>
: If set to zero, a replica will always consider itself valid, and will therefore always try to failover a master, regardless of the amount of time the link between the master and the replica remained disconnected. If the value is positive, a maximum disconnection time is calculated as the
<em>
node timeout
</em>
value multiplied by the factor provided with this option, and if the node is a replica, it will not try to start a failover if the master link was disconnected for more than the specified amount of time. For example, if the node timeout is set to 5 seconds and the validity factor is set to 10, a replica disconnected from the master for more than 50 seconds will not try to failover its master. Note that any value different than zero may result in Redis Cluster being unavailable after a master failure if there is no replica that is able to failover it. In that case the cluster will return to being available only when the original master rejoins the cluster.
</li>
<li>
<strong>
cluster-migration-barrier
<code>
<count>
</code>
</strong>
: Minimum number of replicas a master will remain connected with, for another replica to migrate to a master which is no longer covered by any replica. See the appropriate section about replica migration in this tutorial for more information.
</li>
<li>
<strong>
cluster-require-full-coverage
<code>
<yes/no>
</code>
</strong>
: If this is set to yes, as it is by default, the cluster stops accepting writes if some percentage of the key space is not covered by any node. If the option is set to no, the cluster will still serve queries even if only requests about a subset of keys can be processed.
</li>
<li>
<strong>
cluster-allow-reads-when-down
<code>
<yes/no>
</code>
</strong>
: If this is set to no, as it is by default, a node in a Redis Cluster will stop serving all traffic when the cluster is marked as failed, either when a node can't reach a quorum of masters or when full coverage is not met. This prevents reading potentially inconsistent data from a node that is unaware of changes in the cluster. This option can be set to yes to allow reads from a node during the fail state, which is useful for applications that want to prioritize read availability but still want to prevent inconsistent writes. It can also be used for when using Redis Cluster with only one or two shards, as it allows the nodes to continue serving writes when a master fails but automatic failover is impossible.
</li>
</ul>
<h2 id="create-and-use-a-redis-cluster">
Create and use a Redis Cluster
</h2>
<p>
To create and use a Redis Cluster, follow these steps:
</p>
<ul>
<li>
<a href="#create-a-redis-cluster">
Create a Redis Cluster
</a>
</li>
<li>
<a href="#interact-with-the-cluster">
Interact with the cluster
</a>
</li>
<li>
<a href="#write-an-example-app-with-redis-rb-cluster">
Write an example app with redis-rb-cluster
</a>
</li>
<li>
<a href="#reshard-the-cluster">
Reshard the cluster
</a>
</li>
<li>
<a href="#a-more-interesting-example-application">
A more interesting example application
</a>
</li>
<li>
<a href="#test-the-failover">
Test the failover
</a>
</li>
<li>
<a href="#manual-failover">
Manual failover
</a>
</li>
<li>
<a href="#add-a-new-node">
Add a new node
</a>
</li>
<li>
<a href="#remove-a-node">
Remove a node
</a>
</li>
<li>
<a href="#replica-migration">
Replica migration
</a>
</li>
<li>
<a href="#upgrade-nodes-in-a-redis-cluster">
Upgrade nodes in a Redis Cluster
</a>
</li>
<li>
<a href="#migrate-to-redis-cluster">
Migrate to Redis Cluster
</a>
</li>
</ul>
<p>
But, first, familiarize yourself with the requirements for creating a cluster.
</p>
<h4 id="requirements-to-create-a-redis-cluster">
Requirements to create a Redis Cluster
</h4>
<p>
To create a cluster, the first thing you need is to have a few empty Redis instances running in
<em>
cluster mode
</em>
.
</p>
<p>
At minimum, set the following directives in the
<code>
redis.conf
</code>
file:
</p>
<pre tabindex="0"><code>port 7000
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
appendonly yes
</code></pre>
<p>
To enable cluster mode, set the
<code>
cluster-enabled
</code>
directive to
<code>
yes
</code>
.
Every instance also contains the path of a file where the
configuration for this node is stored, which by default is
<code>
nodes.conf
</code>
.
This file is never touched by humans; it is simply generated at startup
by the Redis Cluster instances, and updated every time it is needed.
</p>
<p>
Note that the
<strong>
minimal cluster
</strong>
that works as expected must contain
at least three master nodes. For deployment, we strongly recommend
a six-node cluster, with three masters and three replicas.
</p>
<p>
You can test this locally by creating the following directories named
after the port number of the instance you'll run inside any given directory.
</p>
<p>
For example:
</p>
<pre tabindex="0"><code>mkdir cluster-test
cd cluster-test
mkdir 7000 7001 7002 7003 7004 7005
</code></pre>
<p>
Create a
<code>
redis.conf
</code>
file inside each of the directories, from 7000 to 7005.
As a template for your configuration file just use the small example above,
but make sure to replace the port number
<code>
7000
</code>
with the right port number
according to the directory name.
</p>
<p>
You can start each instance as follows, each running in a separate terminal tab:
</p>
<pre tabindex="0"><code>cd 7000
redis-server ./redis.conf
</code></pre>
<p>
You'll see from the logs that every node assigns itself a new ID:
</p>
<pre><code>[82462] 26 Nov 11:56:55.329 * No cluster configuration found, I'm 97a3a64667477371c4479320d683e4c8db5858b1
</code></pre>
<p>
This ID will be used forever by this specific instance in order for the instance
to have a unique name in the context of the cluster. Every node
remembers every other node using this IDs, and not by IP or port.
IP addresses and ports may change, but the unique node identifier will never
change for all the life of the node. We call this identifier simply
<strong>
Node ID
</strong>
.
</p>
<h4 id="create-a-redis-cluster">
Create a Redis Cluster
</h4>
<p>
Now that we have a number of instances running, you need to create your cluster by writing some meaningful configuration to the nodes.
</p>
<p>
You can configure and execute individual instances manually or use the create-cluster script.
Let's go over how you do it manually.
</p>
<p>
To create the cluster, run:
</p>
<pre><code>redis-cli --cluster create 127.0.0.1:7000 127.0.0.1:7001 \
127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 \
--cluster-replicas 1
</code></pre>
<p>
The command used here is
<strong>
create
</strong>
, since we want to create a new cluster.
The option
<code>
--cluster-replicas 1
</code>
means that we want a replica for every master created.
</p>
<p>
The other arguments are the list of addresses of the instances I want to use
to create the new cluster.
</p>
<p>
<code>
redis-cli
</code>
will propose a configuration. Accept the proposed configuration by typing
<strong>
yes
</strong>
.
The cluster will be configured and
<em>
joined
</em>
, which means that instances will be
bootstrapped into talking with each other. Finally, if everything has gone well, you'll see a message like this:
</p>
<pre><code>[OK] All 16384 slots covered
</code></pre>
<p>
This means that there is at least one master instance serving each of the
16384 available slots.
</p>
<p>
If you don't want to create a Redis Cluster by configuring and executing
individual instances manually as explained above, there is a much simpler
system (but you'll not learn the same amount of operational details).
</p>
<p>
Find the
<code>
utils/create-cluster
</code>
directory in the Redis distribution.
There is a script called
<code>
create-cluster
</code>
inside (same name as the directory
it is contained into), it's a simple bash script. In order to start
a 6 nodes cluster with 3 masters and 3 replicas just type the following
commands:
</p>
<ol>
<li>
<code>
create-cluster start
</code>
</li>
<li>
<code>
create-cluster create
</code>
</li>
</ol>
<p>
Reply to
<code>
yes
</code>
in step 2 when the
<code>
redis-cli
</code>
utility wants you to accept
the cluster layout.
</p>
<p>
You can now interact with the cluster, the first node will start at port 30001
by default. When you are done, stop the cluster with:
</p>
<ol start="3">
<li>
<code>
create-cluster stop
</code>
</li>
</ol>
<p>
Please read the
<code>
README
</code>
inside this directory for more information on how
to run the script.
</p>
<h4 id="interact-with-the-cluster">
Interact with the cluster
</h4>
<p>
To connect to Redis Cluster, you'll need a cluster-aware Redis client.
See the
<a href="/docs/latest/develop/clients/">
documentation
</a>
for your client of choice to determine its cluster support.
</p>
<p>
You can also test your Redis Cluster using the
<code>
redis-cli
</code>
command line utility:
</p>
<pre tabindex="0"><code>$ redis-cli -c -p 7000
redis 127.0.0.1:7000> set foo bar
-> Redirected to slot [12182] located at 127.0.0.1:7002
OK
redis 127.0.0.1:7002> set hello world
-> Redirected to slot [866] located at 127.0.0.1:7000
OK
redis 127.0.0.1:7000> get foo
-> Redirected to slot [12182] located at 127.0.0.1:7002
"bar"
redis 127.0.0.1:7002> get hello
-> Redirected to slot [866] located at 127.0.0.1:7000
"world"
</code></pre>
<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 created the cluster using the script, your nodes may listen
on different ports, starting from 30001 by default.
</div>
</div>
<p>
The
<code>
redis-cli
</code>
cluster support is very basic, so it always uses the fact that
Redis Cluster nodes are able to redirect a client to the right node.
A serious client is able to do better than that, and cache the map between
hash slots and nodes addresses, to directly use the right connection to the
right node. The map is refreshed only when something changed in the cluster
configuration, for example after a failover or after the system administrator
changed the cluster layout by adding or removing nodes.
</p>
<h4 id="write-an-example-app-with-redis-rb-cluster">
Write an example app with redis-rb-cluster
</h4>
<p>
Before going forward showing how to operate the Redis Cluster, doing things
like a failover, or a resharding, we need to create some example application
or at least to be able to understand the semantics of a simple Redis Cluster
client interaction.
</p>
<p>
In this way we can run an example and at the same time try to make nodes
failing, or start a resharding, to see how Redis Cluster behaves under real
world conditions. It is not very helpful to see what happens while nobody
is writing to the cluster.
</p>
<p>
This section explains some basic usage of
<a href="https://github.com/antirez/redis-rb-cluster">
redis-rb-cluster
</a>
showing two
examples.
The first is the following, and is the
<a href="https://github.com/antirez/redis-rb-cluster/blob/master/example.rb">
<code>
example.rb
</code>
</a>
file inside the redis-rb-cluster distribution:
</p>
<pre tabindex="0"><code> 1 require './cluster'
2
3 if ARGV.length != 2
4 startup_nodes = [
5 {:host => "127.0.0.1", :port => 7000},
6 {:host => "127.0.0.1", :port => 7001}
7 ]
8 else
9 startup_nodes = [
10 {:host => ARGV[0], :port => ARGV[1].to_i}
11 ]
12 end
13
14 rc = RedisCluster.new(startup_nodes,32,:timeout => 0.1)
15
16 last = false
17
18 while not last
19 begin
20 last = rc.get("__last__")
21 last = 0 if !last
22 rescue => e
23 puts "error #{e.to_s}"
24 sleep 1
25 end
26 end
27
28 ((last.to_i+1)..1000000000).each{|x|
29 begin
30 rc.set("foo#{x}",x)
31 puts rc.get("foo#{x}")
32 rc.set("__last__",x)
33 rescue => e
34 puts "error #{e.to_s}"
35 end
36 sleep 0.1
37 }
</code></pre>
<p>
The application does a very simple thing, it sets keys in the form
<code>
foo<number>
</code>
to
<code>
number
</code>
, one after the other. So if you run the program the result is the
following stream of commands:
</p>
<ul>
<li>
SET foo0 0
</li>
<li>
SET foo1 1
</li>
<li>
SET foo2 2
</li>
<li>
And so forth...
</li>
</ul>
<p>
The program looks more complex than it should usually as it is designed to
show errors on the screen instead of exiting with an exception, so every
operation performed with the cluster is wrapped by
<code>
begin
</code>
<code>
rescue
</code>
blocks.
</p>
<p>
The
<strong>
line 14
</strong>
is the first interesting line in the program. It creates the
Redis Cluster object, using as argument a list of
<em>
startup nodes
</em>
, the maximum
number of connections this object is allowed to take against different nodes,
and finally the timeout after a given operation is considered to be failed.
</p>
<p>
The startup nodes don't need to be all the nodes of the cluster. The important
thing is that at least one node is reachable. Also note that redis-rb-cluster
updates this list of startup nodes as soon as it is able to connect with the
first node. You should expect such a behavior with any other serious client.
</p>
<p>
Now that we have the Redis Cluster object instance stored in the
<strong>
rc
</strong>
variable,
we are ready to use the object like if it was a normal Redis object instance.
</p>
<p>
This is exactly what happens in
<strong>
line 18 to 26
</strong>
: when we restart the example
we don't want to start again with
<code>
foo0
</code>
, so we store the counter inside
Redis itself. The code above is designed to read this counter, or if the
counter does not exist, to assign it the value of zero.
</p>
<p>
However note how it is a while loop, as we want to try again and again even
if the cluster is down and is returning errors. Normal applications don't need
to be so careful.
</p>
<p>
<strong>
Lines between 28 and 37
</strong>
start the main loop where the keys are set or
an error is displayed.
</p>
<p>
Note the
<code>
sleep
</code>
call at the end of the loop. In your tests you can remove
the sleep if you want to write to the cluster as fast as possible (relatively
to the fact that this is a busy loop without real parallelism of course, so
you'll get the usually 10k ops/second in the best of the conditions).
</p>
<p>
Normally writes are slowed down in order for the example application to be
easier to follow by humans.
</p>
<p>
Starting the application produces the following output:
</p>
<pre tabindex="0"><code>ruby ./example.rb
1
2
3
4
5
6
7
8
9
^C (I stopped the program here)
</code></pre>
<p>
This is not a very interesting program and we'll use a better one in a moment
but we can already see what happens during a resharding when the program
is running.
</p>
<h4 id="reshard-the-cluster">
Reshard the cluster
</h4>
<p>
Now we are ready to try a cluster resharding. To do this, please
keep the example.rb program running, so that you can see if there is some
impact on the program running. Also, you may want to comment the
<code>
sleep
</code>
call to have some more serious write load during resharding.
</p>
<p>
Resharding basically means to move hash slots from a set of nodes to another
set of nodes.
Like cluster creation, it is accomplished using the redis-cli utility.
</p>
<p>
To start a resharding, just type:
</p>
<pre><code>redis-cli --cluster reshard 127.0.0.1:7000
</code></pre>
<p>
You only need to specify a single node, redis-cli will find the other nodes
automatically.
</p>
<p>
Currently redis-cli is only able to reshard with the administrator support,
you can't just say move 5% of slots from this node to the other one (but
this is pretty trivial to implement). So it starts with questions. The first
is how much of a resharding do you want to do:
</p>
<pre><code>How many slots do you want to move (from 1 to 16384)?
</code></pre>
<p>
We can try to reshard 1000 hash slots, that should already contain a non
trivial amount of keys if the example is still running without the sleep
call.
</p>
<p>
Then redis-cli needs to know what is the target of the resharding, that is,
the node that will receive the hash slots.
I'll use the first master node, that is, 127.0.0.1:7000, but I need
to specify the Node ID of the instance. This was already printed in a
list by redis-cli, but I can always find the ID of a node with the following
command if I need:
</p>
<pre tabindex="0"><code>$ redis-cli -p 7000 cluster nodes | grep myself
97a3a64667477371c4479320d683e4c8db5858b1 :0 myself,master - 0 0 0 connected 0-5460
</code></pre>
<p>
Ok so my target node is 97a3a64667477371c4479320d683e4c8db5858b1.
</p>
<p>
Now you'll get asked from what nodes you want to take those keys.
I'll just type
<code>
all
</code>
in order to take a bit of hash slots from all the
other master nodes.
</p>
<p>
After the final confirmation you'll see a message for every slot that
redis-cli is going to move from a node to another, and a dot will be printed
for every actual key moved from one side to the other.
</p>
<p>
While the resharding is in progress you should be able to see your
example program running unaffected. You can stop and restart it multiple times
during the resharding if you want.
</p>
<p>
At the end of the resharding, you can test the health of the cluster with
the following command:
</p>
<pre><code>redis-cli --cluster check 127.0.0.1:7000
</code></pre>
<p>
All the slots will be covered as usual, but this time the master at
127.0.0.1:7000 will have more hash slots, something around 6461.
</p>
<p>
Resharding can be performed automatically without the need to manually
enter the parameters in an interactive way. This is possible using a command
line like the following:
</p>
<pre><code>redis-cli --cluster reshard <host>:<port> --cluster-from <node-id> --cluster-to <node-id> --cluster-slots <number of slots> --cluster-yes
</code></pre>
<p>
This allows to build some automatism if you are likely to reshard often,
however currently there is no way for
<code>
redis-cli
</code>
to automatically
rebalance the cluster checking the distribution of keys across the cluster
nodes and intelligently moving slots as needed. This feature will be added
in the future.
</p>
<p>
The
<code>
--cluster-yes
</code>
option instructs the cluster manager to automatically answer
"yes" to the command's prompts, allowing it to run in a non-interactive mode.
Note that this option can also be activated by setting the
<code>
REDISCLI_CLUSTER_YES
</code>
environment variable.
</p>
<h4 id="a-more-interesting-example-application">
A more interesting example application
</h4>
<p>
The example application we wrote early is not very good.
It writes to the cluster in a simple way without even checking if what was
written is the right thing.
</p>
<p>
From our point of view the cluster receiving the writes could just always
write the key
<code>
foo
</code>
to
<code>
42
</code>
to every operation, and we would not notice at
all.
</p>
<p>
So in the
<code>
redis-rb-cluster
</code>
repository, there is a more interesting application
that is called
<code>
consistency-test.rb
</code>
. It uses a set of counters, by default 1000, and sends
<a href="/commands/incr">
<code>
INCR
</code>
</a>
commands in order to increment the counters.
</p>
<p>
However instead of just writing, the application does two additional things:
</p>
<ul>
<li>
When a counter is updated using
<a href="/commands/incr">
<code>
INCR
</code>
</a>
, the application remembers the write.
</li>
<li>
It also reads a random counter before every write, and check if the value is what we expected it to be, comparing it with the value it has in memory.
</li>
</ul>
<p>
What this means is that this application is a simple
<strong>
consistency checker
</strong>
,
and is able to tell you if the cluster lost some write, or if it accepted
a write that we did not receive acknowledgment for. In the first case we'll
see a counter having a value that is smaller than the one we remember, while
in the second case the value will be greater.
</p>
<p>
Running the consistency-test application produces a line of output every
second:
</p>
<pre tabindex="0"><code>$ ruby consistency-test.rb
925 R (0 err) | 925 W (0 err) |
5030 R (0 err) | 5030 W (0 err) |
9261 R (0 err) | 9261 W (0 err) |
13517 R (0 err) | 13517 W (0 err) |
17780 R (0 err) | 17780 W (0 err) |
22025 R (0 err) | 22025 W (0 err) |
25818 R (0 err) | 25818 W (0 err) |
</code></pre>
<p>
The line shows the number of
<strong>
R
</strong>
eads and
<strong>
W
</strong>
rites performed, and the
number of errors (query not accepted because of errors since the system was
not available).
</p>
<p>
If some inconsistency is found, new lines are added to the output.
This is what happens, for example, if I reset a counter manually while
the program is running:
</p>
<pre tabindex="0"><code>$ redis-cli -h 127.0.0.1 -p 7000 set key_217 0
OK
(in the other tab I see...)
94774 R (0 err) | 94774 W (0 err) |
98821 R (0 err) | 98821 W (0 err) |
102886 R (0 err) | 102886 W (0 err) | 114 lost |
107046 R (0 err) | 107046 W (0 err) | 114 lost |
</code></pre>
<p>
When I set the counter to 0 the real value was 114, so the program reports
114 lost writes (
<a href="/commands/incr">
<code>
INCR
</code>
</a>
commands that are not remembered by the cluster).
</p>
<p>
This program is much more interesting as a test case, so we'll use it
to test the Redis Cluster failover.
</p>
<h4 id="test-the-failover">
Test the failover
</h4>
<p>
To trigger the failover, the simplest thing we can do (that is also
the semantically simplest failure that can occur in a distributed system)
is to crash a single process, in our case a single master.
</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>
During this test, you should take a tab open with the consistency test
application running.
</div>
</div>
<p>
We can identify a master and crash it with the following command:
</p>
<pre tabindex="0"><code>$ redis-cli -p 7000 cluster nodes | grep master
3e3a6cb0d9a9a87168e266b0a0b24026c0aae3f0 127.0.0.1:7001 master - 0 1385482984082 0 connected 5960-10921
2938205e12de373867bf38f1ca29d31d0ddb3e46 127.0.0.1:7002 master - 0 1385482983582 0 connected 11423-16383
97a3a64667477371c4479320d683e4c8db5858b1 :0 myself,master - 0 0 0 connected 0-5959 10922-11422
</code></pre>
<p>
Ok, so 7000, 7001, and 7002 are masters. Let's crash node 7002 with the
<strong>
DEBUG SEGFAULT
</strong>
command:
</p>
<pre tabindex="0"><code>$ redis-cli -p 7002 debug segfault
Error: Server closed the connection
</code></pre>
<p>
Now we can look at the output of the consistency test to see what it reported.
</p>
<pre tabindex="0"><code>18849 R (0 err) | 18849 W (0 err) |
23151 R (0 err) | 23151 W (0 err) |
27302 R (0 err) | 27302 W (0 err) |
... many error warnings here ...
29659 R (578 err) | 29660 W (577 err) |
33749 R (578 err) | 33750 W (577 err) |
37918 R (578 err) | 37919 W (577 err) |
42077 R (578 err) | 42078 W (577 err) |
</code></pre>
<p>
As you can see during the failover the system was not able to accept 578 reads and 577 writes, however no inconsistency was created in the database. This may
sound unexpected as in the first part of this tutorial we stated that Redis
Cluster can lose writes during the failover because it uses asynchronous
replication. What we did not say is that this is not very likely to happen
because Redis sends the reply to the client, and the commands to replicate
to the replicas, about at the same time, so there is a very small window to
lose data. However the fact that it is hard to trigger does not mean that it
is impossible, so this does not change the consistency guarantees provided
by Redis cluster.
</p>
<p>
We can now check what is the cluster setup after the failover (note that
in the meantime I restarted the crashed instance so that it rejoins the
cluster as a replica):
</p>
<pre tabindex="0"><code>$ redis-cli -p 7000 cluster nodes
3fc783611028b1707fd65345e763befb36454d73 127.0.0.1:7004 slave 3e3a6cb0d9a9a87168e266b0a0b24026c0aae3f0 0 1385503418521 0 connected
a211e242fc6b22a9427fed61285e85892fa04e08 127.0.0.1:7003 slave 97a3a64667477371c4479320d683e4c8db5858b1 0 1385503419023 0 connected
97a3a64667477371c4479320d683e4c8db5858b1 :0 myself,master - 0 0 0 connected 0-5959 10922-11422
3c3a0c74aae0b56170ccb03a76b60cfe7dc1912e 127.0.0.1:7005 master - 0 1385503419023 3 connected 11423-16383
3e3a6cb0d9a9a87168e266b0a0b24026c0aae3f0 127.0.0.1:7001 master - 0 1385503417005 0 connected 5960-10921
2938205e12de373867bf38f1ca29d31d0ddb3e46 127.0.0.1:7002 slave 3c3a0c74aae0b56170ccb03a76b60cfe7dc1912e 0 1385503418016 3 connected
</code></pre>
<p>
Now the masters are running on ports 7000, 7001 and 7005. What was previously
a master, that is the Redis instance running on port 7002, is now a replica of
7005.
</p>
<p>
The output of the
<a href="/commands/cluster-nodes">
<code>
CLUSTER NODES
</code>
</a>
command may look intimidating, but it is actually pretty simple, and is composed of the following tokens:
</p>
<ul>
<li>
Node ID
</li>
<li>
ip:port
</li>
<li>
flags: master, replica, myself, fail, ...
</li>
<li>
if it is a replica, the Node ID of the master
</li>
<li>
Time of the last pending PING still waiting for a reply.
</li>
<li>
Time of the last PONG received.
</li>
<li>
Configuration epoch for this node (see the Cluster specification).
</li>
<li>
Status of the link to this node.
</li>
<li>
Slots served...
</li>
</ul>
<h4 id="manual-failover">
Manual failover
</h4>
<p>
Sometimes it is useful to force a failover without actually causing any problem
on a master. For example, to upgrade the Redis process of one of the
master nodes it is a good idea to failover it to turn it into a replica
with minimal impact on availability.
</p>
<p>
Manual failovers are supported by Redis Cluster using the
<a href="/commands/cluster-failover">
<code>
CLUSTER FAILOVER
</code>
</a>
command, that must be executed in one of the replicas of the master you want
to failover.
</p>
<p>
Manual failovers are special and are safer compared to failovers resulting from
actual master failures. They occur in a way that avoids data loss in the
process, by switching clients from the original master to the new master only
when the system is sure that the new master processed all the replication stream
from the old one.
</p>
<p>
This is what you see in the replica log when you perform a manual failover:
</p>
<pre><code># Manual failover user request accepted.
# Received replication offset for paused master manual failover: 347540
# All master replication stream processed, manual failover can start.
# Start of election delayed for 0 milliseconds (rank #0, offset 347540).
# Starting a failover election for epoch 7545.
# Failover election won: I'm the new master.
</code></pre>
<p>
Basically clients connected to the master we are failing over are stopped.
At the same time the master sends its replication offset to the replica, that
waits to reach the offset on its side. When the replication offset is reached,
the failover starts, and the old master is informed about the configuration
switch. When the clients are unblocked on the old master, they are redirected
to the new master.
</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>
To promote a replica to master, it must first be known as a replica by a majority of the masters in the cluster.
Otherwise, it cannot win the failover election.
If the replica has just been added to the cluster (see
<a href="#add-a-new-node-as-a-replica">
Add a new node as a replica
</a>
), you may need to wait a while before sending the
<a href="/commands/cluster-failover">
<code>
CLUSTER FAILOVER
</code>
</a>
command, to make sure the masters in cluster are aware of the new replica.
</div>
</div>
<h4 id="add-a-new-node">
Add a new node
</h4>
<p>
Adding a new node is basically the process of adding an empty node and then
moving some data into it, in case it is a new master, or telling it to
setup as a replica of a known node, in case it is a replica.
</p>
<p>
We'll show both, starting with the addition of a new master instance.
</p>
<p>
In both cases the first step to perform is
<strong>
adding an empty node
</strong>
.
</p>
<p>
This is as simple as to start a new node in port 7006 (we already used
from 7000 to 7005 for our existing 6 nodes) with the same configuration
used for the other nodes, except for the port number, so what you should
do in order to conform with the setup we used for the previous nodes:
</p>
<ul>
<li>
Create a new tab in your terminal application.
</li>
<li>
Enter the
<code>
cluster-test
</code>
directory.
</li>
<li>
Create a directory named
<code>
7006
</code>
.
</li>
<li>
Create a redis.conf file inside, similar to the one used for the other nodes but using 7006 as port number.
</li>
<li>
Finally start the server with
<code>
../redis-server ./redis.conf
</code>
</li>
</ul>
<p>
At this point the server should be running.
</p>
<p>
Now we can use
<strong>
redis-cli
</strong>
as usual in order to add the node to
the existing cluster.
</p>
<pre><code>redis-cli --cluster add-node 127.0.0.1:7006 127.0.0.1:7000
</code></pre>
<p>
As you can see I used the
<strong>
add-node
</strong>
command specifying the address of the
new node as first argument, and the address of a random existing node in the
cluster as second argument.
</p>
<p>
In practical terms redis-cli here did very little to help us, it just
sent a
<a href="/commands/cluster-meet">
<code>
CLUSTER MEET
</code>
</a>
message to the node, something that is also possible
to accomplish manually. However redis-cli also checks the state of the
cluster before to operate, so it is a good idea to perform cluster operations
always via redis-cli even when you know how the internals work.
</p>
<p>
Now we can connect to the new node to see if it really joined the cluster:
</p>
<pre tabindex="0"><code>redis 127.0.0.1:7006> cluster nodes
3e3a6cb0d9a9a87168e266b0a0b24026c0aae3f0 127.0.0.1:7001 master - 0 1385543178575 0 connected 5960-10921
3fc783611028b1707fd65345e763befb36454d73 127.0.0.1:7004 slave 3e3a6cb0d9a9a87168e266b0a0b24026c0aae3f0 0 1385543179583 0 connected
f093c80dde814da99c5cf72a7dd01590792b783b :0 myself,master - 0 0 0 connected
2938205e12de373867bf38f1ca29d31d0ddb3e46 127.0.0.1:7002 slave 3c3a0c74aae0b56170ccb03a76b60cfe7dc1912e 0 1385543178072 3 connected
a211e242fc6b22a9427fed61285e85892fa04e08 127.0.0.1:7003 slave 97a3a64667477371c4479320d683e4c8db5858b1 0 1385543178575 0 connected
97a3a64667477371c4479320d683e4c8db5858b1 127.0.0.1:7000 master - 0 1385543179080 0 connected 0-5959 10922-11422
3c3a0c74aae0b56170ccb03a76b60cfe7dc1912e 127.0.0.1:7005 master - 0 1385543177568 3 connected 11423-16383
</code></pre>
<p>
Note that since this node is already connected to the cluster it is already
able to redirect client queries correctly and is generally speaking part of
the cluster. However it has two peculiarities compared to the other masters:
</p>
<ul>
<li>
It holds no data as it has no assigned hash slots.
</li>
<li>
Because it is a master without assigned slots, it does not participate in the election process when a replica wants to become a master.
</li>
</ul>
<p>
Now it is possible to assign hash slots to this node using the resharding
feature of
<code>
redis-cli
</code>
.
It is basically useless to show this as we already
did in a previous section, there is no difference, it is just a resharding
having as a target the empty node.
</p>
<h5 id="add-a-new-node-as-a-replica">
Add a new node as a replica
</h5>
<p>
Adding a new replica can be performed in two ways. The obvious one is to
use redis-cli again, but with the --cluster-slave option, like this:
</p>
<pre><code>redis-cli --cluster add-node 127.0.0.1:7006 127.0.0.1:7000 --cluster-slave
</code></pre>
<p>
Note that the command line here is exactly like the one we used to add
a new master, so we are not specifying to which master we want to add
the replica. In this case, what happens is that redis-cli will add the new
node as replica of a random master among the masters with fewer replicas.
</p>
<p>
However you can specify exactly what master you want to target with your
new replica with the following command line:
</p>
<pre><code>redis-cli --cluster add-node 127.0.0.1:7006 127.0.0.1:7000 --cluster-slave --cluster-master-id 3c3a0c74aae0b56170ccb03a76b60cfe7dc1912e
</code></pre>
<p>
This way we assign the new replica to a specific master.
</p>
<p>
A more manual way to add a replica to a specific master is to add the new
node as an empty master, and then turn it into a replica using the
<a href="/commands/cluster-replicate">
<code>
CLUSTER REPLICATE
</code>
</a>
command. This also works if the node was added as a replica
but you want to move it as a replica of a different master.
</p>
<p>
For example in order to add a replica for the node 127.0.0.1:7005 that is
currently serving hash slots in the range 11423-16383, that has a Node ID
3c3a0c74aae0b56170ccb03a76b60cfe7dc1912e, all I need to do is to connect
with the new node (already added as empty master) and send the command:
</p>
<pre><code>redis 127.0.0.1:7006> cluster replicate 3c3a0c74aae0b56170ccb03a76b60cfe7dc1912e
</code></pre>
<p>
That's it. Now we have a new replica for this set of hash slots, and all
the other nodes in the cluster already know (after a few seconds needed to
update their config). We can verify with the following command:
</p>
<pre tabindex="0"><code>$ redis-cli -p 7000 cluster nodes | grep slave | grep 3c3a0c74aae0b56170ccb03a76b60cfe7dc1912e
f093c80dde814da99c5cf72a7dd01590792b783b 127.0.0.1:7006 slave 3c3a0c74aae0b56170ccb03a76b60cfe7dc1912e 0 1385543617702 3 connected
2938205e12de373867bf38f1ca29d31d0ddb3e46 127.0.0.1:7002 slave 3c3a0c74aae0b56170ccb03a76b60cfe7dc1912e 0 1385543617198 3 connected
</code></pre>
<p>
The node 3c3a0c... now has two replicas, running on ports 7002 (the existing one) and 7006 (the new one).
</p>
<h4 id="remove-a-node">
Remove a node
</h4>
<p>
To remove a replica node just use the
<code>
del-node
</code>
command of redis-cli:
</p>
<pre><code>redis-cli --cluster del-node 127.0.0.1:7000 `<node-id>`
</code></pre>
<p>
The first argument is just a random node in the cluster, the second argument
is the ID of the node you want to remove.
</p>
<p>
You can remove a master node in the same way as well,
<strong>
however in order to
remove a master node it must be empty
</strong>
. If the master is not empty you need
to reshard data away from it to all the other master nodes before.
</p>
<p>
An alternative to remove a master node is to perform a manual failover of it
over one of its replicas and remove the node after it turned into a replica of the
new master. Obviously this does not help when you want to reduce the actual
number of masters in your cluster, in that case, a resharding is needed.
</p>
<p>
There is a special scenario where you want to remove a failed node.
You should not use the
<code>
del-node
</code>
command because it tries to connect to all nodes and you will encounter a "connection refused" error.
Instead, you can use the
<code>
call
</code>
command:
</p>
<pre><code>redis-cli --cluster call 127.0.0.1:7000 cluster forget `<node-id>`
</code></pre>
<p>
This command will execute
<a href="/commands/cluster-forget">
<code>
CLUSTER FORGET
</code>
</a>
command on every node.
</p>
<h4 id="replica-migration">
Replica migration
</h4>
<p>
In Redis Cluster, you can reconfigure a replica to replicate with a
different master at any time just using this command:
</p>
<pre><code>CLUSTER REPLICATE <master-node-id>
</code></pre>
<p>
However there is a special scenario where you want replicas to move from one
master to another one automatically, without the help of the system administrator.
The automatic reconfiguration of replicas is called
<em>
replicas migration
</em>
and is
able to improve the reliability of a Redis Cluster.
</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>
You can read the details of replicas migration in the
<a href="/docs/latest/operate/oss_and_stack/reference/cluster-spec/">
Redis Cluster Specification
</a>
, here we'll only provide some information about the
general idea and what you should do in order to benefit from it.
</div>
</div>
<p>
The reason why you may want to let your cluster replicas to move from one master
to another under certain condition, is that usually the Redis Cluster is as
resistant to failures as the number of replicas attached to a given master.
</p>
<p>
For example a cluster where every master has a single replica can't continue
operations if the master and its replica fail at the same time, simply because
there is no other instance to have a copy of the hash slots the master was
serving. However while net-splits are likely to isolate a number of nodes
at the same time, many other kind of failures, like hardware or software failures
local to a single node, are a very notable class of failures that are unlikely
to happen at the same time, so it is possible that in your cluster where
every master has a replica, the replica is killed at 4am, and the master is killed
at 6am. This still will result in a cluster that can no longer operate.
</p>
<p>
To improve reliability of the system we have the option to add additional
replicas to every master, but this is expensive. Replica migration allows to
add more replicas to just a few masters. So you have 10 masters with 1 replica
each, for a total of 20 instances. However you add, for example, 3 instances
more as replicas of some of your masters, so certain masters will have more
than a single replica.
</p>
<p>
With replicas migration what happens is that if a master is left without
replicas, a replica from a master that has multiple replicas will migrate to
the
<em>
orphaned
</em>
master. So after your replica goes down at 4am as in the example
we made above, another replica will take its place, and when the master
will fail as well at 5am, there is still a replica that can be elected so that
the cluster can continue to operate.
</p>
<p>
So what you should know about replicas migration in short?
</p>
<ul>
<li>
The cluster will try to migrate a replica from the master that has the greatest number of replicas in a given moment.
</li>
<li>
To benefit from replica migration you have just to add a few more replicas to a single master in your cluster, it does not matter what master.
</li>
<li>
There is a configuration parameter that controls the replica migration feature that is called
<code>
cluster-migration-barrier
</code>
: you can read more about it in the example
<code>
redis.conf
</code>
file provided with Redis Cluster.
</li>
</ul>
<h4 id="upgrade-nodes-in-a-redis-cluster">
Upgrade nodes in a Redis Cluster
</h4>
<p>
Upgrading replica nodes is easy since you just need to stop the node and restart
it with an updated version of Redis. If there are clients scaling reads using
replica nodes, they should be able to reconnect to a different replica if a given
one is not available.
</p>
<p>
Upgrading masters is a bit more complex, and the suggested procedure is:
</p>
<ol>
<li>
Use
<a href="/commands/cluster-failover">
<code>
CLUSTER FAILOVER
</code>
</a>
to trigger a manual failover of the master to one of its replicas.
(See the
<a href="#manual-failover">
Manual failover
</a>
in this topic.)
</li>
<li>
Wait for the master to turn into a replica.
</li>
<li>
Finally upgrade the node as you do for replicas.
</li>
<li>
If you want the master to be the node you just upgraded, trigger a new manual failover in order to turn back the upgraded node into a master.
</li>
</ol>
<p>
Following this procedure you should upgrade one node after the other until
all the nodes are upgraded.
</p>
<h4 id="migrate-to-redis-cluster">
Migrate to Redis Cluster
</h4>
<p>
Users willing to migrate to Redis Cluster may have just a single master, or
may already using a preexisting sharding setup, where keys
are split among N nodes, using some in-house algorithm or a sharding algorithm
implemented by their client library or Redis proxy.
</p>
<p>
In both cases it is possible to migrate to Redis Cluster easily, however
what is the most important detail is if multiple-keys operations are used
by the application, and how. There are three different cases:
</p>
<ol>
<li>
Multiple keys operations, or transactions, or Lua scripts involving multiple keys, are not used. Keys are accessed independently (even if accessed via transactions or Lua scripts grouping multiple commands, about the same key, together).
</li>
<li>
Multiple keys operations, or transactions, or Lua scripts involving multiple keys are used but only with keys having the same
<strong>
hash tag
</strong>
, which means that the keys used together all have a
<code>
{...}
</code>
sub-string that happens to be identical. For example the following multiple keys operation is defined in the context of the same hash tag:
<code>
SUNION {user:1000}.foo {user:1000}.bar
</code>
.
</li>
<li>
Multiple keys operations, or transactions, or Lua scripts involving multiple keys are used with key names not having an explicit, or the same, hash tag.
</li>
</ol>
<p>
The third case is not handled by Redis Cluster: the application requires to
be modified in order to not use multi keys operations or only use them in
the context of the same hash tag.
</p>
<p>
Case 1 and 2 are covered, so we'll focus on those two cases, that are handled
in the same way, so no distinction will be made in the documentation.
</p>
<p>
Assuming you have your preexisting data set split into N masters, where
N=1 if you have no preexisting sharding, the following steps are needed
in order to migrate your data set to Redis Cluster:
</p>
<ol>
<li>
Stop your clients. No automatic live-migration to Redis Cluster is currently possible. You may be able to do it orchestrating a live migration in the context of your application / environment.
</li>
<li>
Generate an append only file for all of your N masters using the
<a href="/commands/bgrewriteaof">
<code>
BGREWRITEAOF
</code>
</a>
command, and waiting for the AOF file to be completely generated.
</li>
<li>
Save your AOF files from aof-1 to aof-N somewhere. At this point you can stop your old instances if you wish (this is useful since in non-virtualized deployments you often need to reuse the same computers).
</li>
<li>
Create a Redis Cluster composed of N masters and zero replicas. You'll add replicas later. Make sure all your nodes are using the append only file for persistence.
</li>
<li>
Stop all the cluster nodes, substitute their append only file with your pre-existing append only files, aof-1 for the first node, aof-2 for the second node, up to aof-N.
</li>
<li>
Restart your Redis Cluster nodes with the new AOF files. They'll complain that there are keys that should not be there according to their configuration.
</li>
<li>
Use
<code>
redis-cli --cluster fix
</code>
command in order to fix the cluster so that keys will be migrated according to the hash slots each node is authoritative or not.
</li>
<li>
Use
<code>
redis-cli --cluster check
</code>
at the end to make sure your cluster is ok.
</li>
<li>
Restart your clients modified to use a Redis Cluster aware client library.
</li>
</ol>
<p>
There is an alternative way to import data from external instances to a Redis
Cluster, which is to use the
<code>
redis-cli --cluster import
</code>
command.
</p>
<p>
The command moves all the keys of a running instance (deleting the keys from
the source instance) to the specified pre-existing Redis Cluster. However
note that if you use a Redis 2.8 instance as source instance the operation
may be slow since 2.8 does not implement migrate connection caching, so you
may want to restart your source instance with a Redis 3.x version before
to perform such operation.
</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>
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.
</div>
</div>
<h2 id="learn-more">
Learn more
</h2>
<ul>
<li>
<a href="/docs/latest/operate/oss_and_stack/reference/cluster-spec/">
Redis Cluster specification
</a>
</li>
<li>
<a href="https://redis.com/redis-enterprise/technology/linear-scaling-redis-enterprise/">
Linear Scaling with Redis Enterprise
</a>
</li>
<li>
<a href="https://docs.docker.com/engine/userguide/networking/dockernetworks/">
Docker documentation
</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/oss_and_stack/management/scaling/"/>
<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.del/.html | <section class="prose w-full py-12">
<h1 class="command-name">
JSON.DEL
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">JSON.DEL 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(N) when path is evaluated to a single value where N is the size of the deleted value, O(N) when path is evaluated to multiple values, where N is the size of the key
</dd>
</dl>
<p>
Delete a value
</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 to modify.
</p>
</details>
<h2 id="optional-arguments">
Optional arguments
</h2>
<details open="">
<summary>
<code>
path
</code>
</summary>
<p>
is JSONPath to specify. Default is root
<code>
$
</code>
. Nonexisting paths are ignored.
</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>
Deleting an object's root is equivalent to deleting the key from Redis.
</div>
</div>
</details>
<h2 id="return">
Return
</h2>
<p>
JSON.DEL returns an integer reply specified as the number of paths deleted (0 or more).
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>
Delete a value
</b>
</summary>
<p>
Create a JSON document.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> JSON.SET doc $ <span class="s1">'{"a": 1, "nested": {"a": 2, "b": 3}}'</span>
</span></span><span class="line"><span class="cl">OK</span></span></code></pre>
</div>
<p>
Delete specified values.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> JSON.DEL doc $..a
</span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">2</span></span></span></code></pre>
</div>
<p>
Get the updated document.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> JSON.GET doc $
</span></span><span class="line"><span class="cl"><span class="s2">"[{\"nested\":{\"b\":3}}]"</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.arrlen/">
<code>
JSON.ARRLEN
</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.del/"/>
<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/develop/data-types/sets/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Sets in Active-Active databases
</h1>
<p class="text-lg -mt-5 mb-10">
Information about using sets with an Active-Active database.
</p>
<p>
A Redis set is an unordered collection of strings. It is possible to
add, remove, and test for the existence of members with Redis commands.
A Redis set maintains a unique collection of elements. Sets can be great
for maintaining a list of events (click streams), users (in a group
conversation), products (in recommendation lists), engagements (likes,
shares) and so on.
</p>
<p>
Sets 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 across multiple Active-Active database instances
are typically unioned except in cases of conflicts. Conflicting instance
writes can happen when aΒ Active-Active database instance deletes an element while the
other adds the same element. In this case and observed remove rule is
followed. That is, remove can only remove instances it has already seen
and in all other cases element add wins.
</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">
SADD 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">
SADD key1 βbβ
</td>
</tr>
<tr>
<td style="text-align:right">
t3
</td>
<td style="text-align:center">
SMEMBERS key1 βaβ
</td>
<td style="text-align:center">
SMEMBERS key1 β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">
t3
</td>
<td style="text-align:center">
SMEMBERS key1 βaβ βbβ
</td>
<td style="text-align:center">
SMEMBERS key1 βaβ βbβ
</td>
</tr>
</tbody>
</table>
<p>
Here is an example of an "observed remove" 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">
SMEMBERS key1 βaβ βbβ
</td>
<td style="text-align:center">
SMEMBERS key1 βaβ βbβ
</td>
</tr>
<tr>
<td style="text-align:right">
t2
</td>
<td style="text-align:center">
SREM key1 βaβ
</td>
<td style="text-align:center">
SADD key1 βcβ
</td>
</tr>
<tr>
<td style="text-align:right">
t3
</td>
<td style="text-align:center">
SREM key1 βcβ
</td>
<td style="text-align:center">
</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">
t3
</td>
<td style="text-align:center">
SMEMBERS key1 βcβ βbβ
</td>
<td style="text-align:center">
SMEMBERS key1 βcβ βbβ
</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/databases/active-active/develop/data-types/sets/"/>
<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.info/.html | <section class="prose w-full py-12">
<h1 class="command-name">
BF.INFO
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">BF.INFO key [CAPACITY | SIZE | FILTERS | ITEMS | EXPANSION]</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(1)
</dd>
</dl>
<p>
Returns information about a Bloom filter.
</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="optional-arguments">
Optional arguments
</h2>
<details open="">
<summary>
<code>
CAPACITY
</code>
</summary>
<p>
Return the number of unique items that can be stored in this Bloom filter before scaling would be required (including already added items).
</p>
</details>
<details open="">
<summary>
<code>
SIZE
</code>
</summary>
<p>
Return the memory size: number of bytes allocated for this Bloom filter.
</p>
</details>
<details open="">
<summary>
<code>
FILTERS
</code>
</summary>
<p>
Return the number of sub-filters.
</p>
</details>
<details open="">
<summary>
<code>
ITEMS
</code>
</summary>
<p>
Return 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).
</p>
</details>
<details open="">
<summary>
<code>
EXPANSION
</code>
</summary>
<p>
Return the expansion rate.
</p>
</details>
<p>
When no optional argument is specified: return all information fields.
</p>
<h2 id="return-value">
Return value
</h2>
<p>
When no optional argument is specified, returns one of these replies:
</p>
<ul>
<li>
<a href="/docs/latest/develop/reference/protocol-spec/#arrays">
Array reply
</a>
with argument name (
<a href="/docs/latest/develop/reference/protocol-spec/#simple-strings">
Simple string reply
</a>
) and value (
<a href="/docs/latest/develop/reference/protocol-spec/#integers">
Integer reply
</a>
) pairs
</li>
<li>
[] on error (invalid arguments, key does not exist, wrong key type, and so on)
</li>
</ul>
<p>
When an optional argument is specified, returns one of these replies:
</p>
<ul>
<li>
<a href="/docs/latest/develop/reference/protocol-spec/#integers">
Integer reply
</a>
- argument value
</li>
<li>
[] on error (invalid arguments, key does not exist, wrong key type, and so on)
</li>
</ul>
<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> BF.ADD bf1 observation1
</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> BF.INFO bf1
</span></span><span class="line"><span class="cl"> 1<span class="o">)</span> Capacity
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">100</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> Size
</span></span><span class="line"><span class="cl"> 4<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">240</span>
</span></span><span class="line"><span class="cl"> 5<span class="o">)</span> Number of filters
</span></span><span class="line"><span class="cl"> 6<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"> 7<span class="o">)</span> Number of items inserted
</span></span><span class="line"><span class="cl"> 8<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"> 9<span class="o">)</span> Expansion rate
</span></span><span class="line"><span class="cl">10<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">2</span>
</span></span><span class="line"><span class="cl">redis> BF.INFO bf1 CAPACITY
</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">100</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.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/operate/rs/installing-upgrading/quickstarts/docker-quickstart/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Docker quickstart for Redis Enterprise Software
</h1>
<p class="text-lg -mt-5 mb-10">
Set up a development or test deployment of Redis Enterprise Software using Docker.
</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>
Docker containers are currently only supported for development and test environments, not for production. Use
<a href="/docs/latest/operate/kubernetes/">
Redis Enterprise on Kubernetes
</a>
for a supported containerized deployment.
</div>
</div>
<p>
For testing purposes, you can run Redis Enterprise Software on Docker containers on
Linux, Windows, or MacOS.
The
<a href="https://hub.docker.com/r/redislabs/redis/">
Redis Enterprise Software container
</a>
acts as a node in a cluster.
</p>
<p>
To get started with a single Redis Enterprise Software container:
</p>
<ol>
<li>
<p>
<a href="#install-docker">
Install Docker
</a>
for your operating system
</p>
</li>
<li>
<p>
<a href="#run-the-container">
Run the Redis Enterprise Software Docker container
</a>
</p>
</li>
<li>
<p>
<a href="#set-up-a-cluster">
Set up a cluster
</a>
</p>
</li>
<li>
<p>
<a href="#create-a-database">
Create a new database
</a>
</p>
</li>
<li>
<p>
<a href="#connect-to-your-database">
Connect to your database
</a>
</p>
</li>
</ol>
<h2 id="install-docker">
Install Docker
</h2>
<p>
Follow the Docker installation instructions for your operating system:
</p>
<ul>
<li>
<a href="https://docs.docker.com/install/#supported-platforms">
Linux
</a>
</li>
<li>
<a href="https://docs.docker.com/docker-for-mac/install/">
MacOS
</a>
</li>
<li>
<a href="https://store.docker.com/editions/community/docker-ce-desktop-windows">
Windows
</a>
</li>
</ul>
<h2 id="run-the-container">
Run the container
</h2>
<p>
To download and start the Redis Enterprise Software Docker container, run the following
<a href="https://docs.docker.com/engine/reference/commandline/run/">
<code>
docker run
</code>
</a>
command in the terminal or command line for your operating system.
</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>
On Windows, make sure Docker is configured to run Linux-based containers.
</div>
</div>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">docker run -d --cap-add sys_resource --name RE -p 8443:8443 -p 9443:9443 -p 12000:12000 redislabs/redis
</span></span></code></pre>
</div>
<p>
The example command runs the Docker container with Redis Enterprise Software on
<code>
localhost
</code>
and opens the following ports:
</p>
<ul>
<li>
<p>
Port 8443 for HTTPS connections
</p>
</li>
<li>
<p>
Port 9443 for
<a href="/docs/latest/operate/rs/references/rest-api/">
REST API
</a>
connections
</p>
</li>
<li>
<p>
Port 12000 configured Redis database port allowing client connections
</p>
</li>
</ul>
<p>
You can publish other
<a href="/docs/latest/operate/rs/networking/port-configurations/">
ports
</a>
with
<code>
-p <host_port>:<container_port>
</code>
or use the
<code>
--network host
</code>
option to open all ports to the host network.
</p>
<h2 id="set-up-a-cluster">
Set up a cluster
</h2>
<ol>
<li>
<p>
In the web browser on the host machine, go to
<a href="https://localhost:8443">
https://localhost:8443
</a>
to see
the new Redis Enterprise Software Cluster Manager UI. The cluster generates self-signed TLS certificates to secure the connection. These self-signed certificates are unknown to the browser and must be accepted before you proceed.
</p>
<p>
To use the legacy UI for this quickstart instead, see the
<a href="https://docs.redis.com/6.4/rs/installing-upgrading/quickstarts/">
6.4 version of the quickstarts
</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>
If the server does not show the login screen, try again after a few minutes.
</li>
</ul>
</div>
</div>
</li>
<li>
<p>
Select
<strong>
Create new cluster
</strong>
.
</p>
<a href="/docs/latest/images/rs/screenshots/cluster/setup/create-cluster.png" sdata-lightbox="/images/rs/screenshots/cluster/setup/create-cluster.png">
<img alt="When you first install Redis Enterprise Software, you need to set up a cluster." src="/docs/latest/images/rs/screenshots/cluster/setup/create-cluster.png"/>
</a>
</li>
<li>
<p>
Enter an email and password for the administrator account, then select
<strong>
Next
</strong>
to proceed to cluster setup.
</p>
<a href="/docs/latest/images/rs/screenshots/cluster/setup/admin-credentials.png" sdata-lightbox="/images/rs/screenshots/cluster/setup/admin-credentials.png">
<img alt="Set the credentials for your admin user." src="/docs/latest/images/rs/screenshots/cluster/setup/admin-credentials.png"/>
</a>
<p>
You can also use these credentials to connect to the
<a href="/docs/latest/operate/rs/references/rest-api/">
REST API
</a>
.
</p>
</li>
<li>
<p>
Enter your cluster license key if you have one. Otherwise, a trial version is installed.
</p>
<a href="/docs/latest/images/rs/screenshots/cluster/setup/cluster-license-key.png" sdata-lightbox="/images/rs/screenshots/cluster/setup/cluster-license-key.png">
<img alt="Enter your cluster license key if you have one." src="/docs/latest/images/rs/screenshots/cluster/setup/cluster-license-key.png"/>
</a>
</li>
<li>
<p>
In the
<strong>
Configuration
</strong>
section, enter a cluster FQDN such as
<code>
cluster.local
</code>
, then select
<strong>
Next
</strong>
.
</p>
<a href="/docs/latest/images/rs/screenshots/cluster/setup/config-cluster.png" sdata-lightbox="/images/rs/screenshots/cluster/setup/config-cluster.png">
<img alt="Configure the cluster FQDN." src="/docs/latest/images/rs/screenshots/cluster/setup/config-cluster.png"/>
</a>
<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 the FQDN is
<code>
cluster.local
</code>
, you cannot configure DNS. You cannot change the FQDN after cluster creation.
</div>
</div>
</li>
<li>
<p>
On the node setup screen, select
<strong>
Create cluster
</strong>
to accept the defaults.
</p>
<a href="/docs/latest/images/rs/screenshots/cluster/setup/node-settings.png" sdata-lightbox="/images/rs/screenshots/cluster/setup/node-settings.png">
<img alt="Configure the node specific settings." src="/docs/latest/images/rs/screenshots/cluster/setup/node-settings.png"/>
</a>
</li>
<li>
<p>
Select
<strong>
OK
</strong>
to acknowledge the replacement of the HTTPS TLS certificate on the node. If you receive a browser warning, you can proceed safely.
</p>
<a href="/docs/latest/images/rs/screenshots/cluster/setup/https-page-refresh-modal.png" sdata-lightbox="/images/rs/screenshots/cluster/setup/https-page-refresh-modal.png">
<img alt="Modal shown when a page refresh is needed because the certificates have been updated." src="/docs/latest/images/rs/screenshots/cluster/setup/https-page-refresh-modal.png"/>
</a>
</li>
</ol>
<h2 id="create-a-database">
Create a database
</h2>
<ol>
<li>
<p>
On the
<strong>
Databases
</strong>
screen, select
<strong>
Quick database
</strong>
.
</p>
<a href="/docs/latest/images/rs/screenshots/databases/db-screen.png" sdata-lightbox="/images/rs/screenshots/databases/db-screen.png">
<img alt="Select Quick database on the Databases screen." src="/docs/latest/images/rs/screenshots/databases/db-screen.png"/>
</a>
</li>
<li>
<p>
Enter 12000 for the
<strong>
Port
</strong>
.
</p>
<p>
If port 12000 is not available, enter any available port number between 10000 to 19999 or leave it blank to let the cluster assign a port number for you. You will use this port number to connect to the database.
</p>
<a href="/docs/latest/images/rs/screenshots/databases/quick-db-7-8-2.png" sdata-lightbox="/images/rs/screenshots/databases/quick-db-7-8-2.png">
<img alt="Create a quick database." src="/docs/latest/images/rs/screenshots/databases/quick-db-7-8-2.png"/>
</a>
</li>
<li>
<p>
Select
<strong>
Create
</strong>
to create your database.
</p>
</li>
</ol>
<p>
When you see
<strong>
Database active
</strong>
appear on the database configuration screen, the database is activated and ready for you to use.
</p>
<a href="/docs/latest/images/rs/icons/db-active-icon.png" sdata-lightbox="/images/rs/icons/db-active-icon.png">
<img alt="Database active icon." src="/docs/latest/images/rs/icons/db-active-icon.png" width="150px"/>
</a>
<p>
You now have a Redis database!
</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 cannot activate the database because of a memory limitation,
make sure that Docker has at least 4 GB of memory allocated in the
<strong>
Advanced
</strong>
section of Docker
<strong>
Settings
</strong>
.
</div>
</div>
<h2 id="connect-to-your-database">
Connect to your database
</h2>
<p>
After you create the Redis database, you can connect to it to begin storing data.
</p>
<h3 id="connect-inside-docker">
Use redis-cli inside Docker
</h3>
<p>
Every installation of Redis Enterprise Software includes the command-line tool
<a href="/docs/latest/operate/rs/references/cli-utilities/redis-cli/">
<code>
redis-cli
</code>
</a>
to interact with your Redis database. You can use
<code>
redis-cli
</code>
to connect to your database from within the same Docker network.
</p>
<p>
Use
<a href="https://docs.docker.com/engine/reference/commandline/exec/">
<code>
docker exec
</code>
</a>
to start an interactive
<code>
redis-cli
</code>
session in the running Redis Enterprise Software container:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ docker <span class="nb">exec</span> -it redis-cli -h redis-12000.cluster.local -p <span class="m">12000</span>
</span></span><span class="line"><span class="cl">127.0.0.1:12000> SET key1 <span class="m">123</span>
</span></span><span class="line"><span class="cl">OK
</span></span><span class="line"><span class="cl">127.0.0.1:12000> GET key1
</span></span><span class="line"><span class="cl"><span class="s2">"123"</span>
</span></span></code></pre>
</div>
<h3 id="connect-outside-docker">
Connect from the host environment
</h3>
<p>
The database you created uses port
<code>
12000
</code>
, which is also mapped from the Docker container back to the host environment. This lets you use any method you have available locally to
<a href="/docs/latest/operate/rs/databases/connect/">
connect to a Redis database
</a>
. Use
<code>
localhost
</code>
as the
<code>
host
</code>
and
<code>
12000
</code>
as the port.
</p>
<h2 id="test-different-topologies">
Test different topologies
</h2>
<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>
Docker containers are currently only supported for development and test environments, not for production. Use
<a href="/docs/latest/operate/kubernetes/">
Redis Enterprise on Kubernetes
</a>
for a supported containerized deployment.
</div>
</div>
<p>
When deploying Redis Enterprise Software using Docker for testing, several common topologies are available, according to your requirements:
</p>
<ul>
<li>
<p>
<a href="#single-node">
Single-node cluster
</a>
β For local development or functional testing
</p>
</li>
<li>
<p>
<a href="#multi-node-one-host">
Multi-node cluster on a single host
</a>
β For a small-scale deployment that is similar to production
</p>
</li>
<li>
<p>
<a href="#multi-node-multi-host">
Multi-node cluster with multiple hosts
</a>
β For more predictable performance or high availability compared to single-host deployments
</p>
</li>
</ul>
<h3 id="single-node">
Single node
</h3>
<p>
The simplest topology is to run a single-node Redis Enterprise Software cluster with a single container on a single host machine. You can use this topology for local development or functional testing.
</p>
<p>
Single-node clusters have limited functionality. For example, Redis Enterprise Software can't use replication or protect against failures if the cluster has only one node.
</p>
<a href="/docs/latest/images/rs/RS-Docker-container.png" sdata-lightbox="/images/rs/RS-Docker-container.png">
<img src="/docs/latest/images/rs/RS-Docker-container.png"/>
</a>
<h3 id="multi-node-one-host">
Multiple nodes on one host
</h3>
<p>
You can create a multi-node Redis Enterprise Software cluster by deploying multiple containers to a single host machine. The resulting cluster is scale minimized but similar to production deployments.
</p>
<p>
However, this will also have several limitations. For example, you cannot map the same port on multiple containers on the same host.
</p>
<a href="/docs/latest/images/rs/RS-Docker-cluster-single-host.png" sdata-lightbox="/images/rs/RS-Docker-cluster-single-host.png">
<img src="/docs/latest/images/rs/RS-Docker-cluster-single-host.png"/>
</a>
<h3 id="multi-node-multi-host">
Multiple nodes and hosts
</h3>
<p>
You can create a multi-node Redis Enterprise Software cluster with multiple containers by deploying each container to a different host machine.
</p>
<p>
This topology minimizes interference between containers, allowing for the testing of more Redis Enterprise Software features.
</p>
<a href="/docs/latest/images/rs/RS-Docker-cluster-multi-host.png" sdata-lightbox="/images/rs/RS-Docker-cluster-multi-host.png">
<img src="/docs/latest/images/rs/RS-Docker-cluster-multi-host.png"/>
</a>
<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/quickstarts/docker-quickstart/"/>
<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/export_reset_status/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Export resets status database action requests
</h1>
<p class="text-lg -mt-5 mb-10">
Reset database export 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-export-reset-status">
PUT
</a>
</td>
<td>
<code>
/v1/bdbs/{uid}/actions/export_reset_status
</code>
</td>
<td>
Reset database export status
</td>
</tr>
</tbody>
</table>
<h2 id="put-bdbs-actions-export-reset-status">
Reset database export status
</h2>
<pre><code>PUT /v1/bdbs/{int: uid}/actions/export_reset_status
</code></pre>
<p>
Resets the database's
<code>
export_status
</code>
to idle if an export is not in progress and clears the value of the
<code>
export_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/7.4/references/rest-api/permissions/#reset_bdb_current_export_status">
reset_bdb_current_export_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/export_reset_status
</span></span></code></pre>
</div>
<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>
<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/7.4/references/rest-api/requests/bdbs/actions/export_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/operate/oss_and_stack/stack-with-enterprise/release-notes/redisstack/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Redis Stack release notes
</h1>
<p class="text-lg -mt-5 mb-10">
Redis Stack release notes for version 7.2 and later
</p>
<table>
<thead>
<tr>
<th style="text-align:left">
VersionΒ (ReleaseΒ date)
</th>
<th style="text-align:left">
MajorΒ changes
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisstack/redisstack-6.2.6-release-notes/">
v6.2.6-v0 (December 2022)
</a>
</td>
<td style="text-align:left">
Redis Stack 6.2.6 release notes.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisstack/redisstack-7.2-release-notes/">
v7.2.0-v0 (August 2023)
</a>
</td>
<td style="text-align:left">
Redis Stack 7.2 release notes.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisstack/redisstack-7.4-release-notes/">
v7.4.0-v0 (July 2024)
</a>
</td>
<td style="text-align:left">
Redis Stack 7.4 release notes.
</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/oss_and_stack/stack-with-enterprise/release-notes/redisstack/"/>
<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/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/7.4/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/7.4/databases/durability-ha/clustering/#supported-hashing-policies">
hashing policy
</a>
.
</li>
<li>
Have the
<a href="/docs/latest/operate/rs/7.4/databases/configure/proxy-policy/">
proxy policy
</a>
set to either
<code>
all-master-shards
</code>
or
<code>
all-nodes
</code>
.
</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/7.4/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>
Turn on the
<strong>
OSS Cluster API
</strong>
toggle.
</p>
<a href="/docs/latest/images/rs/screenshots/databases/config-clustering-oss-cluster-api.png" sdata-lightbox="/images/rs/screenshots/databases/config-clustering-oss-cluster-api.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.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/7.4/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/7.4/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 <database name or ID> 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>
Ensure the
<a href="/docs/latest/operate/rs/7.4/databases/configure/oss-cluster-api/#prerequisites">
prerequisites
</a>
have been configured. Then, use the
<code>
crdb-cli
</code>
utility to enable the OSS Cluster API for Active-Active databases:
</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 <GUID> --oss-cluster <span class="nb">true</span>
</span></span></code></pre>
</div>
<p>
For best results, you should do this when you first create the database.
</p>
<p>
Here's the basic process:
</p>
<ol>
<li>
<p>
Create the 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 create --name <name> <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span> --memory-size 10g --port <port> <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><fqdn>,username<span class="o">=</span><user>,password<span class="o">=</span><pass> <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><fqdn>,username<span class="o">=</span><user>,password<span class="o">=</span><pass> <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><fqdn>,username<span class="o">=</span><user>,password<span class="o">=</span><pass>
</span></span></code></pre>
</div>
</li>
<li>
<p>
Obtain the CRDB-GUID ID 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"><CRDB-GUID> Test <span class="m">4</span> cluster1.local
</span></span></code></pre>
</div>
</li>
<li>
<p>
Use the CRDB-GUID ID 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 <CRDB-GUID> <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>
<p>
The OSS Cluster API setting applies to all of the instances of the Active-Active database.
</p>
<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>
toggle from 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 <name or ID> oss_cluster disabled
</span></span></code></pre>
</div>
<p>
For Active-Active databases, use
<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 <CRDB-GUID> <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/7.4/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/7.4/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/develop/clients/dotnet/queryjson/.html | <section class="prose w-full py-12">
<h1>
Example - Index and query JSON documents
</h1>
<p class="text-lg -mt-5 mb-10">
Learn how to use the Redis query engine with JSON
</p>
<p>
This example shows how to create a
<a href="/docs/latest/develop/interact/search-and-query/indexing/">
search index
</a>
for
<a href="/docs/latest/develop/data-types/json/">
JSON
</a>
data and
run queries against the index.
</p>
<p>
Make sure that you have Redis Stack and
<code>
NRedisStack
</code>
installed.
</p>
<p>
Start by importing dependencies:
</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="cs_home_json-stepimport">
<input checked="" class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_cs_home_json-stepimport" name="cs_home_json-stepimport" 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_cs_home_json-stepimport" title="Open example">
C#
</label>
<div aria-labelledby="tab-cs_home_json-stepimport" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_cs_home_json-stepimport" 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 hl"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.RedisStackCommands</span><span class="p">;</span>
</span></span><span class="line hl"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Search</span><span class="p">;</span>
</span></span><span class="line hl"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Search.Aggregation</span><span class="p">;</span>
</span></span><span class="line hl"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Search.Literals.Enums</span><span class="p">;</span>
</span></span><span class="line hl"><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 class="k">public</span> <span class="k">class</span> <span class="nc">HomeJsonExample</span>
</span></span><span class="line"><span 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">var</span> <span class="n">user1</span> <span class="p">=</span> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">name</span> <span class="p">=</span> <span class="s">"Paul John"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">email</span> <span class="p">=</span> <span class="s">"[email protected]"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">age</span> <span class="p">=</span> <span class="m">42</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">city</span> <span class="p">=</span> <span class="s">"London"</span>
</span></span><span class="line"><span class="cl"> <span class="p">};</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">user2</span> <span class="p">=</span> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">name</span> <span class="p">=</span> <span class="s">"Eden Zamir"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">email</span> <span class="p">=</span> <span class="s">"[email protected]"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">age</span> <span class="p">=</span> <span class="m">29</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">city</span> <span class="p">=</span> <span class="s">"Tel Aviv"</span>
</span></span><span class="line"><span class="cl"> <span class="p">};</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">user3</span> <span class="p">=</span> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">name</span> <span class="p">=</span> <span class="s">"Paul Zamir"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">email</span> <span class="p">=</span> <span class="s">"[email protected]"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">age</span> <span class="p">=</span> <span class="m">35</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">city</span> <span class="p">=</span> <span class="s">"Tel Aviv"</span>
</span></span><span class="line"><span class="cl"> <span class="p">};</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">schema</span> <span class="p">=</span> <span class="k">new</span> <span class="n">Schema</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddTextField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.name"</span><span class="p">,</span> <span class="s">"name"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddTagField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.city"</span><span class="p">,</span> <span class="s">"city"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddNumericField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.age"</span><span class="p">,</span> <span class="s">"age"</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">indexCreated</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Create</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:users"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">FTCreateParams</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">On</span><span class="p">(</span><span class="n">IndexDataType</span><span class="p">.</span><span class="n">JSON</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">Prefix</span><span class="p">(</span><span class="s">"user:"</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">schema</span>
</span></span><span class="line"><span 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">// Tests for 'make_index' 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">user1Set</span> <span 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">"user:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">user1</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">user2Set</span> <span 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">"user:2"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">user2</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">user3Set</span> <span 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">"user:3"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">user3</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'add_data' 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">SearchResult</span> <span class="n">findPaulResult</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:users"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"Paul @age:[30 40]"</span><span class="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="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</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 class="n">findPaulResult</span><span class="p">.</span><span class="n">Documents</span><span class="p">.</span><span class="n">Select</span><span class="p">(</span><span class="n">x</span> <span class="p">=></span> <span class="n">x</span><span class="p">[</span><span class="s">"json"</span><span class="p">])</span>
</span></span><span class="line"><span class="cl"> <span class="p">));</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> {"name":"Paul Zamir","email":"[email protected]", ...</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'query1' 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">var</span> <span class="n">citiesResult</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:users"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"Paul"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">ReturnFields</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.city"</span><span class="p">,</span> <span class="s">"city"</span><span class="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="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</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 class="n">citiesResult</span><span class="p">.</span><span class="n">Documents</span><span class="p">.</span><span class="n">Select</span><span class="p">(</span><span class="n">x</span> <span class="p">=></span> <span class="n">x</span><span class="p">[</span><span class="s">"city"</span><span class="p">]).</span><span class="n">OrderBy</span><span class="p">(</span><span class="n">x</span> <span class="p">=></span> <span class="n">x</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">));</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> London, Tel Aviv</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'query2' 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">AggregationRequest</span> <span class="n">aggRequest</span> <span class="p">=</span> <span class="k">new</span> <span class="n">AggregationRequest</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="n">GroupBy</span><span class="p">(</span><span class="s">"@city"</span><span class="p">,</span> <span class="n">Reducers</span><span class="p">.</span><span class="n">Count</span><span class="p">().</span><span class="n">As</span><span class="p">(</span><span class="s">"count"</span><span class="p">));</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">AggregationResult</span> <span class="n">aggResult</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Aggregate</span><span class="p">(</span><span class="s">"idx:users"</span><span class="p">,</span> <span class="n">aggRequest</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">IReadOnlyList</span><span class="p"><</span><span class="n">Dictionary</span><span class="p"><</span><span class="kt">string</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">>></span> <span class="n">resultsList</span> <span class="p">=</span>
</span></span><span class="line"><span class="cl"> <span class="n">aggResult</span><span class="p">.</span><span class="n">GetResults</span><span class="p">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="p">(</span><span class="kt">var</span> <span class="n">i</span> <span class="p">=</span> <span class="m">0</span><span class="p">;</span> <span class="n">i</span> <span class="p"><</span> <span class="n">resultsList</span><span class="p">.</span><span class="n">Count</span><span class="p">;</span> <span class="n">i</span><span class="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">Dictionary</span><span class="p"><</span><span class="kt">string</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">></span> <span class="n">item</span> <span class="p">=</span> <span class="n">resultsList</span><span class="p">.</span><span class="n">ElementAt</span><span class="p">(</span><span class="n">i</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{item["</span><span class="n">city</span><span class="s">"]} - {item["</span><span class="n">count</span><span class="s">"]}"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> London - 1</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> Tel Aviv - 2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'query3' 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_cs_home_json-stepimport')" 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_cs_home_json-stepimport" 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/HomeJsonExample.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>
Connect to the 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="cs_home_json-stepconnect">
<input checked="" class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_cs_home_json-stepconnect" name="cs_home_json-stepconnect" 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_cs_home_json-stepconnect" title="Open example">
C#
</label>
<div aria-labelledby="tab-cs_home_json-stepconnect" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_cs_home_json-stepconnect" 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.Search</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Search.Aggregation</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Search.Literals.Enums</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 class="k">public</span> <span class="k">class</span> <span class="nc">HomeJsonExample</span>
</span></span><span class="line"><span 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 hl"><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 hl"><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">var</span> <span class="n">user1</span> <span class="p">=</span> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">name</span> <span class="p">=</span> <span class="s">"Paul John"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">email</span> <span class="p">=</span> <span class="s">"[email protected]"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">age</span> <span class="p">=</span> <span class="m">42</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">city</span> <span class="p">=</span> <span class="s">"London"</span>
</span></span><span class="line"><span class="cl"> <span class="p">};</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">user2</span> <span class="p">=</span> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">name</span> <span class="p">=</span> <span class="s">"Eden Zamir"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">email</span> <span class="p">=</span> <span class="s">"[email protected]"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">age</span> <span class="p">=</span> <span class="m">29</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">city</span> <span class="p">=</span> <span class="s">"Tel Aviv"</span>
</span></span><span class="line"><span class="cl"> <span class="p">};</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">user3</span> <span class="p">=</span> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">name</span> <span class="p">=</span> <span class="s">"Paul Zamir"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">email</span> <span class="p">=</span> <span class="s">"[email protected]"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">age</span> <span class="p">=</span> <span class="m">35</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">city</span> <span class="p">=</span> <span class="s">"Tel Aviv"</span>
</span></span><span class="line"><span class="cl"> <span class="p">};</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">schema</span> <span class="p">=</span> <span class="k">new</span> <span class="n">Schema</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddTextField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.name"</span><span class="p">,</span> <span class="s">"name"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddTagField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.city"</span><span class="p">,</span> <span class="s">"city"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddNumericField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.age"</span><span class="p">,</span> <span class="s">"age"</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">indexCreated</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Create</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:users"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">FTCreateParams</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">On</span><span class="p">(</span><span class="n">IndexDataType</span><span class="p">.</span><span class="n">JSON</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">Prefix</span><span class="p">(</span><span class="s">"user:"</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">schema</span>
</span></span><span class="line"><span 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">// Tests for 'make_index' 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">user1Set</span> <span 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">"user:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">user1</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">user2Set</span> <span 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">"user:2"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">user2</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">user3Set</span> <span 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">"user:3"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">user3</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'add_data' 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">SearchResult</span> <span class="n">findPaulResult</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:users"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"Paul @age:[30 40]"</span><span class="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="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</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 class="n">findPaulResult</span><span class="p">.</span><span class="n">Documents</span><span class="p">.</span><span class="n">Select</span><span class="p">(</span><span class="n">x</span> <span class="p">=></span> <span class="n">x</span><span class="p">[</span><span class="s">"json"</span><span class="p">])</span>
</span></span><span class="line"><span class="cl"> <span class="p">));</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> {"name":"Paul Zamir","email":"[email protected]", ...</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'query1' 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">var</span> <span class="n">citiesResult</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:users"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"Paul"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">ReturnFields</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.city"</span><span class="p">,</span> <span class="s">"city"</span><span class="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="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</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 class="n">citiesResult</span><span class="p">.</span><span class="n">Documents</span><span class="p">.</span><span class="n">Select</span><span class="p">(</span><span class="n">x</span> <span class="p">=></span> <span class="n">x</span><span class="p">[</span><span class="s">"city"</span><span class="p">]).</span><span class="n">OrderBy</span><span class="p">(</span><span class="n">x</span> <span class="p">=></span> <span class="n">x</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">));</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> London, Tel Aviv</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'query2' 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">AggregationRequest</span> <span class="n">aggRequest</span> <span class="p">=</span> <span class="k">new</span> <span class="n">AggregationRequest</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="n">GroupBy</span><span class="p">(</span><span class="s">"@city"</span><span class="p">,</span> <span class="n">Reducers</span><span class="p">.</span><span class="n">Count</span><span class="p">().</span><span class="n">As</span><span class="p">(</span><span class="s">"count"</span><span class="p">));</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">AggregationResult</span> <span class="n">aggResult</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Aggregate</span><span class="p">(</span><span class="s">"idx:users"</span><span class="p">,</span> <span class="n">aggRequest</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">IReadOnlyList</span><span class="p"><</span><span class="n">Dictionary</span><span class="p"><</span><span class="kt">string</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">>></span> <span class="n">resultsList</span> <span class="p">=</span>
</span></span><span class="line"><span class="cl"> <span class="n">aggResult</span><span class="p">.</span><span class="n">GetResults</span><span class="p">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="p">(</span><span class="kt">var</span> <span class="n">i</span> <span class="p">=</span> <span class="m">0</span><span class="p">;</span> <span class="n">i</span> <span class="p"><</span> <span class="n">resultsList</span><span class="p">.</span><span class="n">Count</span><span class="p">;</span> <span class="n">i</span><span class="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">Dictionary</span><span class="p"><</span><span class="kt">string</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">></span> <span class="n">item</span> <span class="p">=</span> <span class="n">resultsList</span><span class="p">.</span><span class="n">ElementAt</span><span class="p">(</span><span class="n">i</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{item["</span><span class="n">city</span><span class="s">"]} - {item["</span><span class="n">count</span><span class="s">"]}"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> London - 1</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> Tel Aviv - 2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'query3' 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_cs_home_json-stepconnect')" 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_cs_home_json-stepconnect" 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/HomeJsonExample.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>
Create some test data to add to the 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="cs_home_json-stepcreate_data">
<input checked="" class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_cs_home_json-stepcreate_data" name="cs_home_json-stepcreate_data" 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_cs_home_json-stepcreate_data" title="Open example">
C#
</label>
<div aria-labelledby="tab-cs_home_json-stepcreate_data" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_cs_home_json-stepcreate_data" 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.Search</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Search.Aggregation</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Search.Literals.Enums</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 class="k">public</span> <span class="k">class</span> <span class="nc">HomeJsonExample</span>
</span></span><span class="line"><span 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">var</span> <span class="n">user1</span> <span class="p">=</span> <span class="k">new</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">name</span> <span class="p">=</span> <span class="s">"Paul John"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">email</span> <span class="p">=</span> <span class="s">"[email protected]"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">age</span> <span class="p">=</span> <span class="m">42</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">city</span> <span class="p">=</span> <span class="s">"London"</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="kt">var</span> <span class="n">user2</span> <span class="p">=</span> <span class="k">new</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">name</span> <span class="p">=</span> <span class="s">"Eden Zamir"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">email</span> <span class="p">=</span> <span class="s">"[email protected]"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">age</span> <span class="p">=</span> <span class="m">29</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">city</span> <span class="p">=</span> <span class="s">"Tel Aviv"</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="kt">var</span> <span class="n">user3</span> <span class="p">=</span> <span class="k">new</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">name</span> <span class="p">=</span> <span class="s">"Paul Zamir"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">email</span> <span class="p">=</span> <span class="s">"[email protected]"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">age</span> <span class="p">=</span> <span class="m">35</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">city</span> <span class="p">=</span> <span class="s">"Tel Aviv"</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">};</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">schema</span> <span class="p">=</span> <span class="k">new</span> <span class="n">Schema</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddTextField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.name"</span><span class="p">,</span> <span class="s">"name"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddTagField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.city"</span><span class="p">,</span> <span class="s">"city"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddNumericField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.age"</span><span class="p">,</span> <span class="s">"age"</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">indexCreated</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Create</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:users"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">FTCreateParams</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">On</span><span class="p">(</span><span class="n">IndexDataType</span><span class="p">.</span><span class="n">JSON</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">Prefix</span><span class="p">(</span><span class="s">"user:"</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">schema</span>
</span></span><span class="line"><span 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">// Tests for 'make_index' 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">user1Set</span> <span 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">"user:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">user1</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">user2Set</span> <span 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">"user:2"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">user2</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">user3Set</span> <span 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">"user:3"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">user3</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'add_data' 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">SearchResult</span> <span class="n">findPaulResult</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:users"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"Paul @age:[30 40]"</span><span class="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="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</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 class="n">findPaulResult</span><span class="p">.</span><span class="n">Documents</span><span class="p">.</span><span class="n">Select</span><span class="p">(</span><span class="n">x</span> <span class="p">=></span> <span class="n">x</span><span class="p">[</span><span class="s">"json"</span><span class="p">])</span>
</span></span><span class="line"><span class="cl"> <span class="p">));</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> {"name":"Paul Zamir","email":"[email protected]", ...</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'query1' 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">var</span> <span class="n">citiesResult</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:users"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"Paul"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">ReturnFields</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.city"</span><span class="p">,</span> <span class="s">"city"</span><span class="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="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</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 class="n">citiesResult</span><span class="p">.</span><span class="n">Documents</span><span class="p">.</span><span class="n">Select</span><span class="p">(</span><span class="n">x</span> <span class="p">=></span> <span class="n">x</span><span class="p">[</span><span class="s">"city"</span><span class="p">]).</span><span class="n">OrderBy</span><span class="p">(</span><span class="n">x</span> <span class="p">=></span> <span class="n">x</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">));</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> London, Tel Aviv</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'query2' 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">AggregationRequest</span> <span class="n">aggRequest</span> <span class="p">=</span> <span class="k">new</span> <span class="n">AggregationRequest</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="n">GroupBy</span><span class="p">(</span><span class="s">"@city"</span><span class="p">,</span> <span class="n">Reducers</span><span class="p">.</span><span class="n">Count</span><span class="p">().</span><span class="n">As</span><span class="p">(</span><span class="s">"count"</span><span class="p">));</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">AggregationResult</span> <span class="n">aggResult</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Aggregate</span><span class="p">(</span><span class="s">"idx:users"</span><span class="p">,</span> <span class="n">aggRequest</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">IReadOnlyList</span><span class="p"><</span><span class="n">Dictionary</span><span class="p"><</span><span class="kt">string</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">>></span> <span class="n">resultsList</span> <span class="p">=</span>
</span></span><span class="line"><span class="cl"> <span class="n">aggResult</span><span class="p">.</span><span class="n">GetResults</span><span class="p">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="p">(</span><span class="kt">var</span> <span class="n">i</span> <span class="p">=</span> <span class="m">0</span><span class="p">;</span> <span class="n">i</span> <span class="p"><</span> <span class="n">resultsList</span><span class="p">.</span><span class="n">Count</span><span class="p">;</span> <span class="n">i</span><span class="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">Dictionary</span><span class="p"><</span><span class="kt">string</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">></span> <span class="n">item</span> <span class="p">=</span> <span class="n">resultsList</span><span class="p">.</span><span class="n">ElementAt</span><span class="p">(</span><span class="n">i</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{item["</span><span class="n">city</span><span class="s">"]} - {item["</span><span class="n">count</span><span class="s">"]}"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> London - 1</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> Tel Aviv - 2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'query3' 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_cs_home_json-stepcreate_data')" 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_cs_home_json-stepcreate_data" 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/HomeJsonExample.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>
Create an index. In this example, only JSON documents with the key prefix
<code>
user:
</code>
are indexed. For more information, see
<a href="/docs/latest/develop/interact/search-and-query/query/">
Query syntax
</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="cs_home_json-stepmake_index">
<input checked="" class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_cs_home_json-stepmake_index" name="cs_home_json-stepmake_index" 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_cs_home_json-stepmake_index" title="Open example">
C#
</label>
<div aria-labelledby="tab-cs_home_json-stepmake_index" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_cs_home_json-stepmake_index" 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.Search</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Search.Aggregation</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Search.Literals.Enums</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 class="k">public</span> <span class="k">class</span> <span class="nc">HomeJsonExample</span>
</span></span><span class="line"><span 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">var</span> <span class="n">user1</span> <span class="p">=</span> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">name</span> <span class="p">=</span> <span class="s">"Paul John"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">email</span> <span class="p">=</span> <span class="s">"[email protected]"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">age</span> <span class="p">=</span> <span class="m">42</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">city</span> <span class="p">=</span> <span class="s">"London"</span>
</span></span><span class="line"><span class="cl"> <span class="p">};</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">user2</span> <span class="p">=</span> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">name</span> <span class="p">=</span> <span class="s">"Eden Zamir"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">email</span> <span class="p">=</span> <span class="s">"[email protected]"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">age</span> <span class="p">=</span> <span class="m">29</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">city</span> <span class="p">=</span> <span class="s">"Tel Aviv"</span>
</span></span><span class="line"><span class="cl"> <span class="p">};</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">user3</span> <span class="p">=</span> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">name</span> <span class="p">=</span> <span class="s">"Paul Zamir"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">email</span> <span class="p">=</span> <span class="s">"[email protected]"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">age</span> <span class="p">=</span> <span class="m">35</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">city</span> <span class="p">=</span> <span class="s">"Tel Aviv"</span>
</span></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="kt">var</span> <span class="n">schema</span> <span class="p">=</span> <span class="k">new</span> <span class="n">Schema</span><span class="p">()</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">.</span><span class="n">AddTextField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.name"</span><span class="p">,</span> <span class="s">"name"</span><span class="p">))</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">.</span><span class="n">AddTagField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.city"</span><span class="p">,</span> <span class="s">"city"</span><span class="p">))</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">.</span><span class="n">AddNumericField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.age"</span><span class="p">,</span> <span class="s">"age"</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">indexCreated</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Create</span><span class="p">(</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"idx:users"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="k">new</span> <span class="n">FTCreateParams</span><span class="p">()</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">.</span><span class="n">On</span><span class="p">(</span><span class="n">IndexDataType</span><span class="p">.</span><span class="n">JSON</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">.</span><span class="n">Prefix</span><span class="p">(</span><span class="s">"user:"</span><span class="p">),</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">schema</span>
</span></span><span class="line hl"><span 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">// Tests for 'make_index' 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">user1Set</span> <span 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">"user:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">user1</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">user2Set</span> <span 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">"user:2"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">user2</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">user3Set</span> <span 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">"user:3"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">user3</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'add_data' 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">SearchResult</span> <span class="n">findPaulResult</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:users"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"Paul @age:[30 40]"</span><span class="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="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</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 class="n">findPaulResult</span><span class="p">.</span><span class="n">Documents</span><span class="p">.</span><span class="n">Select</span><span class="p">(</span><span class="n">x</span> <span class="p">=></span> <span class="n">x</span><span class="p">[</span><span class="s">"json"</span><span class="p">])</span>
</span></span><span class="line"><span class="cl"> <span class="p">));</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> {"name":"Paul Zamir","email":"[email protected]", ...</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'query1' 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">var</span> <span class="n">citiesResult</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:users"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"Paul"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">ReturnFields</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.city"</span><span class="p">,</span> <span class="s">"city"</span><span class="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="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</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 class="n">citiesResult</span><span class="p">.</span><span class="n">Documents</span><span class="p">.</span><span class="n">Select</span><span class="p">(</span><span class="n">x</span> <span class="p">=></span> <span class="n">x</span><span class="p">[</span><span class="s">"city"</span><span class="p">]).</span><span class="n">OrderBy</span><span class="p">(</span><span class="n">x</span> <span class="p">=></span> <span class="n">x</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">));</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> London, Tel Aviv</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'query2' 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">AggregationRequest</span> <span class="n">aggRequest</span> <span class="p">=</span> <span class="k">new</span> <span class="n">AggregationRequest</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="n">GroupBy</span><span class="p">(</span><span class="s">"@city"</span><span class="p">,</span> <span class="n">Reducers</span><span class="p">.</span><span class="n">Count</span><span class="p">().</span><span class="n">As</span><span class="p">(</span><span class="s">"count"</span><span class="p">));</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">AggregationResult</span> <span class="n">aggResult</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Aggregate</span><span class="p">(</span><span class="s">"idx:users"</span><span class="p">,</span> <span class="n">aggRequest</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">IReadOnlyList</span><span class="p"><</span><span class="n">Dictionary</span><span class="p"><</span><span class="kt">string</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">>></span> <span class="n">resultsList</span> <span class="p">=</span>
</span></span><span class="line"><span class="cl"> <span class="n">aggResult</span><span class="p">.</span><span class="n">GetResults</span><span class="p">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="p">(</span><span class="kt">var</span> <span class="n">i</span> <span class="p">=</span> <span class="m">0</span><span class="p">;</span> <span class="n">i</span> <span class="p"><</span> <span class="n">resultsList</span><span class="p">.</span><span class="n">Count</span><span class="p">;</span> <span class="n">i</span><span class="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">Dictionary</span><span class="p"><</span><span class="kt">string</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">></span> <span class="n">item</span> <span class="p">=</span> <span class="n">resultsList</span><span class="p">.</span><span class="n">ElementAt</span><span class="p">(</span><span class="n">i</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{item["</span><span class="n">city</span><span class="s">"]} - {item["</span><span class="n">count</span><span class="s">"]}"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> London - 1</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> Tel Aviv - 2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'query3' 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_cs_home_json-stepmake_index')" 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_cs_home_json-stepmake_index" 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/HomeJsonExample.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>
Add the three sets of user data to the database as
<a href="/docs/latest/develop/data-types/json/">
JSON
</a>
objects.
If you use keys with the
<code>
user:
</code>
prefix then Redis will index the
objects automatically as you add them:
</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="cs_home_json-stepadd_data">
<input checked="" class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_cs_home_json-stepadd_data" name="cs_home_json-stepadd_data" 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_cs_home_json-stepadd_data" title="Open example">
C#
</label>
<div aria-labelledby="tab-cs_home_json-stepadd_data" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_cs_home_json-stepadd_data" 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.Search</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Search.Aggregation</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Search.Literals.Enums</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 class="k">public</span> <span class="k">class</span> <span class="nc">HomeJsonExample</span>
</span></span><span class="line"><span 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">var</span> <span class="n">user1</span> <span class="p">=</span> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">name</span> <span class="p">=</span> <span class="s">"Paul John"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">email</span> <span class="p">=</span> <span class="s">"[email protected]"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">age</span> <span class="p">=</span> <span class="m">42</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">city</span> <span class="p">=</span> <span class="s">"London"</span>
</span></span><span class="line"><span class="cl"> <span class="p">};</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">user2</span> <span class="p">=</span> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">name</span> <span class="p">=</span> <span class="s">"Eden Zamir"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">email</span> <span class="p">=</span> <span class="s">"[email protected]"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">age</span> <span class="p">=</span> <span class="m">29</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">city</span> <span class="p">=</span> <span class="s">"Tel Aviv"</span>
</span></span><span class="line"><span class="cl"> <span class="p">};</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">user3</span> <span class="p">=</span> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">name</span> <span class="p">=</span> <span class="s">"Paul Zamir"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">email</span> <span class="p">=</span> <span class="s">"[email protected]"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">age</span> <span class="p">=</span> <span class="m">35</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">city</span> <span class="p">=</span> <span class="s">"Tel Aviv"</span>
</span></span><span class="line"><span class="cl"> <span class="p">};</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">schema</span> <span class="p">=</span> <span class="k">new</span> <span class="n">Schema</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddTextField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.name"</span><span class="p">,</span> <span class="s">"name"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddTagField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.city"</span><span class="p">,</span> <span class="s">"city"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddNumericField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.age"</span><span class="p">,</span> <span class="s">"age"</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">indexCreated</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Create</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:users"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">FTCreateParams</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">On</span><span class="p">(</span><span class="n">IndexDataType</span><span class="p">.</span><span class="n">JSON</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">Prefix</span><span class="p">(</span><span class="s">"user:"</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">schema</span>
</span></span><span class="line"><span 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">// Tests for 'make_index' 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">user1Set</span> <span 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">"user:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">user1</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="kt">bool</span> <span class="n">user2Set</span> <span 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">"user:2"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">user2</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="kt">bool</span> <span class="n">user3Set</span> <span 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">"user:3"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">user3</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'add_data' 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">SearchResult</span> <span class="n">findPaulResult</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:users"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"Paul @age:[30 40]"</span><span class="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="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</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 class="n">findPaulResult</span><span class="p">.</span><span class="n">Documents</span><span class="p">.</span><span class="n">Select</span><span class="p">(</span><span class="n">x</span> <span class="p">=></span> <span class="n">x</span><span class="p">[</span><span class="s">"json"</span><span class="p">])</span>
</span></span><span class="line"><span class="cl"> <span class="p">));</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> {"name":"Paul Zamir","email":"[email protected]", ...</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'query1' 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">var</span> <span class="n">citiesResult</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:users"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"Paul"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">ReturnFields</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.city"</span><span class="p">,</span> <span class="s">"city"</span><span class="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="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</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 class="n">citiesResult</span><span class="p">.</span><span class="n">Documents</span><span class="p">.</span><span class="n">Select</span><span class="p">(</span><span class="n">x</span> <span class="p">=></span> <span class="n">x</span><span class="p">[</span><span class="s">"city"</span><span class="p">]).</span><span class="n">OrderBy</span><span class="p">(</span><span class="n">x</span> <span class="p">=></span> <span class="n">x</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">));</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> London, Tel Aviv</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'query2' 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">AggregationRequest</span> <span class="n">aggRequest</span> <span class="p">=</span> <span class="k">new</span> <span class="n">AggregationRequest</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="n">GroupBy</span><span class="p">(</span><span class="s">"@city"</span><span class="p">,</span> <span class="n">Reducers</span><span class="p">.</span><span class="n">Count</span><span class="p">().</span><span class="n">As</span><span class="p">(</span><span class="s">"count"</span><span class="p">));</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">AggregationResult</span> <span class="n">aggResult</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Aggregate</span><span class="p">(</span><span class="s">"idx:users"</span><span class="p">,</span> <span class="n">aggRequest</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">IReadOnlyList</span><span class="p"><</span><span class="n">Dictionary</span><span class="p"><</span><span class="kt">string</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">>></span> <span class="n">resultsList</span> <span class="p">=</span>
</span></span><span class="line"><span class="cl"> <span class="n">aggResult</span><span class="p">.</span><span class="n">GetResults</span><span class="p">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="p">(</span><span class="kt">var</span> <span class="n">i</span> <span class="p">=</span> <span class="m">0</span><span class="p">;</span> <span class="n">i</span> <span class="p"><</span> <span class="n">resultsList</span><span class="p">.</span><span class="n">Count</span><span class="p">;</span> <span class="n">i</span><span class="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">Dictionary</span><span class="p"><</span><span class="kt">string</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">></span> <span class="n">item</span> <span class="p">=</span> <span class="n">resultsList</span><span class="p">.</span><span class="n">ElementAt</span><span class="p">(</span><span class="n">i</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{item["</span><span class="n">city</span><span class="s">"]} - {item["</span><span class="n">count</span><span class="s">"]}"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> London - 1</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> Tel Aviv - 2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'query3' 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_cs_home_json-stepadd_data')" 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_cs_home_json-stepadd_data" 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/HomeJsonExample.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 now use the index to search the JSON objects. The
<a href="/docs/latest/develop/interact/search-and-query/query/">
query
</a>
below searches for objects that have the text "Paul" in any field
and have an
<code>
age
</code>
value in the range 30 to 40:
</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="cs_home_json-stepquery1">
<input checked="" class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_cs_home_json-stepquery1" name="cs_home_json-stepquery1" 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_cs_home_json-stepquery1" title="Open example">
C#
</label>
<div aria-labelledby="tab-cs_home_json-stepquery1" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_cs_home_json-stepquery1" 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.Search</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Search.Aggregation</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Search.Literals.Enums</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 class="k">public</span> <span class="k">class</span> <span class="nc">HomeJsonExample</span>
</span></span><span class="line"><span 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">var</span> <span class="n">user1</span> <span class="p">=</span> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">name</span> <span class="p">=</span> <span class="s">"Paul John"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">email</span> <span class="p">=</span> <span class="s">"[email protected]"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">age</span> <span class="p">=</span> <span class="m">42</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">city</span> <span class="p">=</span> <span class="s">"London"</span>
</span></span><span class="line"><span class="cl"> <span class="p">};</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">user2</span> <span class="p">=</span> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">name</span> <span class="p">=</span> <span class="s">"Eden Zamir"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">email</span> <span class="p">=</span> <span class="s">"[email protected]"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">age</span> <span class="p">=</span> <span class="m">29</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">city</span> <span class="p">=</span> <span class="s">"Tel Aviv"</span>
</span></span><span class="line"><span class="cl"> <span class="p">};</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">user3</span> <span class="p">=</span> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">name</span> <span class="p">=</span> <span class="s">"Paul Zamir"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">email</span> <span class="p">=</span> <span class="s">"[email protected]"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">age</span> <span class="p">=</span> <span class="m">35</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">city</span> <span class="p">=</span> <span class="s">"Tel Aviv"</span>
</span></span><span class="line"><span class="cl"> <span class="p">};</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">schema</span> <span class="p">=</span> <span class="k">new</span> <span class="n">Schema</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddTextField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.name"</span><span class="p">,</span> <span class="s">"name"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddTagField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.city"</span><span class="p">,</span> <span class="s">"city"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddNumericField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.age"</span><span class="p">,</span> <span class="s">"age"</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">indexCreated</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Create</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:users"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">FTCreateParams</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">On</span><span class="p">(</span><span class="n">IndexDataType</span><span class="p">.</span><span class="n">JSON</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">Prefix</span><span class="p">(</span><span class="s">"user:"</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">schema</span>
</span></span><span class="line"><span 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">// Tests for 'make_index' 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">user1Set</span> <span 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">"user:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">user1</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">user2Set</span> <span 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">"user:2"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">user2</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">user3Set</span> <span 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">"user:3"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">user3</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'add_data' 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">SearchResult</span> <span class="n">findPaulResult</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"idx:users"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"Paul @age:[30 40]"</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="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></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 class="n">findPaulResult</span><span class="p">.</span><span class="n">Documents</span><span class="p">.</span><span class="n">Select</span><span class="p">(</span><span class="n">x</span> <span class="p">=></span> <span class="n">x</span><span class="p">[</span><span class="s">"json"</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="c1">// >>> {"name":"Paul Zamir","email":"[email protected]", ...</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'query1' 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">var</span> <span class="n">citiesResult</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:users"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"Paul"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">ReturnFields</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.city"</span><span class="p">,</span> <span class="s">"city"</span><span class="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="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</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 class="n">citiesResult</span><span class="p">.</span><span class="n">Documents</span><span class="p">.</span><span class="n">Select</span><span class="p">(</span><span class="n">x</span> <span class="p">=></span> <span class="n">x</span><span class="p">[</span><span class="s">"city"</span><span class="p">]).</span><span class="n">OrderBy</span><span class="p">(</span><span class="n">x</span> <span class="p">=></span> <span class="n">x</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">));</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> London, Tel Aviv</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'query2' 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">AggregationRequest</span> <span class="n">aggRequest</span> <span class="p">=</span> <span class="k">new</span> <span class="n">AggregationRequest</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="n">GroupBy</span><span class="p">(</span><span class="s">"@city"</span><span class="p">,</span> <span class="n">Reducers</span><span class="p">.</span><span class="n">Count</span><span class="p">().</span><span class="n">As</span><span class="p">(</span><span class="s">"count"</span><span class="p">));</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">AggregationResult</span> <span class="n">aggResult</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Aggregate</span><span class="p">(</span><span class="s">"idx:users"</span><span class="p">,</span> <span class="n">aggRequest</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">IReadOnlyList</span><span class="p"><</span><span class="n">Dictionary</span><span class="p"><</span><span class="kt">string</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">>></span> <span class="n">resultsList</span> <span class="p">=</span>
</span></span><span class="line"><span class="cl"> <span class="n">aggResult</span><span class="p">.</span><span class="n">GetResults</span><span class="p">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="p">(</span><span class="kt">var</span> <span class="n">i</span> <span class="p">=</span> <span class="m">0</span><span class="p">;</span> <span class="n">i</span> <span class="p"><</span> <span class="n">resultsList</span><span class="p">.</span><span class="n">Count</span><span class="p">;</span> <span class="n">i</span><span class="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">Dictionary</span><span class="p"><</span><span class="kt">string</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">></span> <span class="n">item</span> <span class="p">=</span> <span class="n">resultsList</span><span class="p">.</span><span class="n">ElementAt</span><span class="p">(</span><span class="n">i</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{item["</span><span class="n">city</span><span class="s">"]} - {item["</span><span class="n">count</span><span class="s">"]}"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> London - 1</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> Tel Aviv - 2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'query3' 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_cs_home_json-stepquery1')" 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_cs_home_json-stepquery1" 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/HomeJsonExample.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>
Specify query options to return only the
<code>
city
</code>
field:
</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="cs_home_json-stepquery2">
<input checked="" class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_cs_home_json-stepquery2" name="cs_home_json-stepquery2" 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_cs_home_json-stepquery2" title="Open example">
C#
</label>
<div aria-labelledby="tab-cs_home_json-stepquery2" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_cs_home_json-stepquery2" 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.Search</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Search.Aggregation</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Search.Literals.Enums</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 class="k">public</span> <span class="k">class</span> <span class="nc">HomeJsonExample</span>
</span></span><span class="line"><span 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">var</span> <span class="n">user1</span> <span class="p">=</span> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">name</span> <span class="p">=</span> <span class="s">"Paul John"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">email</span> <span class="p">=</span> <span class="s">"[email protected]"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">age</span> <span class="p">=</span> <span class="m">42</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">city</span> <span class="p">=</span> <span class="s">"London"</span>
</span></span><span class="line"><span class="cl"> <span class="p">};</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">user2</span> <span class="p">=</span> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">name</span> <span class="p">=</span> <span class="s">"Eden Zamir"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">email</span> <span class="p">=</span> <span class="s">"[email protected]"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">age</span> <span class="p">=</span> <span class="m">29</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">city</span> <span class="p">=</span> <span class="s">"Tel Aviv"</span>
</span></span><span class="line"><span class="cl"> <span class="p">};</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">user3</span> <span class="p">=</span> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">name</span> <span class="p">=</span> <span class="s">"Paul Zamir"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">email</span> <span class="p">=</span> <span class="s">"[email protected]"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">age</span> <span class="p">=</span> <span class="m">35</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">city</span> <span class="p">=</span> <span class="s">"Tel Aviv"</span>
</span></span><span class="line"><span class="cl"> <span class="p">};</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">schema</span> <span class="p">=</span> <span class="k">new</span> <span class="n">Schema</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddTextField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.name"</span><span class="p">,</span> <span class="s">"name"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddTagField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.city"</span><span class="p">,</span> <span class="s">"city"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddNumericField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.age"</span><span class="p">,</span> <span class="s">"age"</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">indexCreated</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Create</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:users"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">FTCreateParams</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">On</span><span class="p">(</span><span class="n">IndexDataType</span><span class="p">.</span><span class="n">JSON</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">Prefix</span><span class="p">(</span><span class="s">"user:"</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">schema</span>
</span></span><span class="line"><span 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">// Tests for 'make_index' 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">user1Set</span> <span 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">"user:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">user1</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">user2Set</span> <span 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">"user:2"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">user2</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">user3Set</span> <span 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">"user:3"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">user3</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'add_data' 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">SearchResult</span> <span class="n">findPaulResult</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:users"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"Paul @age:[30 40]"</span><span class="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="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</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 class="n">findPaulResult</span><span class="p">.</span><span class="n">Documents</span><span class="p">.</span><span class="n">Select</span><span class="p">(</span><span class="n">x</span> <span class="p">=></span> <span class="n">x</span><span class="p">[</span><span class="s">"json"</span><span class="p">])</span>
</span></span><span class="line"><span class="cl"> <span class="p">));</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> {"name":"Paul Zamir","email":"[email protected]", ...</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'query1' 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">var</span> <span class="n">citiesResult</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"idx:users"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"Paul"</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">.</span><span class="n">ReturnFields</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.city"</span><span class="p">,</span> <span class="s">"city"</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="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></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 class="n">citiesResult</span><span class="p">.</span><span class="n">Documents</span><span class="p">.</span><span class="n">Select</span><span class="p">(</span><span class="n">x</span> <span class="p">=></span> <span class="n">x</span><span class="p">[</span><span class="s">"city"</span><span class="p">]).</span><span class="n">OrderBy</span><span class="p">(</span><span class="n">x</span> <span class="p">=></span> <span class="n">x</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="c1">// >>> London, Tel Aviv</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'query2' 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">AggregationRequest</span> <span class="n">aggRequest</span> <span class="p">=</span> <span class="k">new</span> <span class="n">AggregationRequest</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="n">GroupBy</span><span class="p">(</span><span class="s">"@city"</span><span class="p">,</span> <span class="n">Reducers</span><span class="p">.</span><span class="n">Count</span><span class="p">().</span><span class="n">As</span><span class="p">(</span><span class="s">"count"</span><span class="p">));</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">AggregationResult</span> <span class="n">aggResult</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Aggregate</span><span class="p">(</span><span class="s">"idx:users"</span><span class="p">,</span> <span class="n">aggRequest</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">IReadOnlyList</span><span class="p"><</span><span class="n">Dictionary</span><span class="p"><</span><span class="kt">string</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">>></span> <span class="n">resultsList</span> <span class="p">=</span>
</span></span><span class="line"><span class="cl"> <span class="n">aggResult</span><span class="p">.</span><span class="n">GetResults</span><span class="p">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="p">(</span><span class="kt">var</span> <span class="n">i</span> <span class="p">=</span> <span class="m">0</span><span class="p">;</span> <span class="n">i</span> <span class="p"><</span> <span class="n">resultsList</span><span class="p">.</span><span class="n">Count</span><span class="p">;</span> <span class="n">i</span><span class="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">Dictionary</span><span class="p"><</span><span class="kt">string</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">></span> <span class="n">item</span> <span class="p">=</span> <span class="n">resultsList</span><span class="p">.</span><span class="n">ElementAt</span><span class="p">(</span><span class="n">i</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{item["</span><span class="n">city</span><span class="s">"]} - {item["</span><span class="n">count</span><span class="s">"]}"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> London - 1</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> Tel Aviv - 2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'query3' 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_cs_home_json-stepquery2')" 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_cs_home_json-stepquery2" 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/HomeJsonExample.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>
Use an
<a href="/docs/latest/develop/interact/search-and-query/query/aggregation/">
aggregation query
</a>
to count all users in each city.
</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="cs_home_json-stepquery3">
<input checked="" class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_cs_home_json-stepquery3" name="cs_home_json-stepquery3" 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_cs_home_json-stepquery3" title="Open example">
C#
</label>
<div aria-labelledby="tab-cs_home_json-stepquery3" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_cs_home_json-stepquery3" 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.Search</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Search.Aggregation</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Search.Literals.Enums</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 class="k">public</span> <span class="k">class</span> <span class="nc">HomeJsonExample</span>
</span></span><span class="line"><span 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">var</span> <span class="n">user1</span> <span class="p">=</span> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">name</span> <span class="p">=</span> <span class="s">"Paul John"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">email</span> <span class="p">=</span> <span class="s">"[email protected]"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">age</span> <span class="p">=</span> <span class="m">42</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">city</span> <span class="p">=</span> <span class="s">"London"</span>
</span></span><span class="line"><span class="cl"> <span class="p">};</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">user2</span> <span class="p">=</span> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">name</span> <span class="p">=</span> <span class="s">"Eden Zamir"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">email</span> <span class="p">=</span> <span class="s">"[email protected]"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">age</span> <span class="p">=</span> <span class="m">29</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">city</span> <span class="p">=</span> <span class="s">"Tel Aviv"</span>
</span></span><span class="line"><span class="cl"> <span class="p">};</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">user3</span> <span class="p">=</span> <span class="k">new</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">name</span> <span class="p">=</span> <span class="s">"Paul Zamir"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">email</span> <span class="p">=</span> <span class="s">"[email protected]"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">age</span> <span class="p">=</span> <span class="m">35</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">city</span> <span class="p">=</span> <span class="s">"Tel Aviv"</span>
</span></span><span class="line"><span class="cl"> <span class="p">};</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">schema</span> <span class="p">=</span> <span class="k">new</span> <span class="n">Schema</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddTextField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.name"</span><span class="p">,</span> <span class="s">"name"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddTagField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.city"</span><span class="p">,</span> <span class="s">"city"</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">AddNumericField</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.age"</span><span class="p">,</span> <span class="s">"age"</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">indexCreated</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Create</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:users"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">FTCreateParams</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">On</span><span class="p">(</span><span class="n">IndexDataType</span><span class="p">.</span><span class="n">JSON</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">Prefix</span><span class="p">(</span><span class="s">"user:"</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">schema</span>
</span></span><span class="line"><span 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">// Tests for 'make_index' 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">user1Set</span> <span 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">"user:1"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">user1</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">user2Set</span> <span 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">"user:2"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">user2</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">user3Set</span> <span 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">"user:3"</span><span class="p">,</span> <span class="s">"$"</span><span class="p">,</span> <span class="n">user3</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'add_data' 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">SearchResult</span> <span class="n">findPaulResult</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:users"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"Paul @age:[30 40]"</span><span class="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="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</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 class="n">findPaulResult</span><span class="p">.</span><span class="n">Documents</span><span class="p">.</span><span class="n">Select</span><span class="p">(</span><span class="n">x</span> <span class="p">=></span> <span class="n">x</span><span class="p">[</span><span class="s">"json"</span><span class="p">])</span>
</span></span><span class="line"><span class="cl"> <span class="p">));</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> {"name":"Paul Zamir","email":"[email protected]", ...</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'query1' 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">var</span> <span class="n">citiesResult</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"idx:users"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">Query</span><span class="p">(</span><span class="s">"Paul"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">.</span><span class="n">ReturnFields</span><span class="p">(</span><span class="k">new</span> <span class="n">FieldName</span><span class="p">(</span><span class="s">"$.city"</span><span class="p">,</span> <span class="s">"city"</span><span class="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="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</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 class="n">citiesResult</span><span class="p">.</span><span class="n">Documents</span><span class="p">.</span><span class="n">Select</span><span class="p">(</span><span class="n">x</span> <span class="p">=></span> <span class="n">x</span><span class="p">[</span><span class="s">"city"</span><span class="p">]).</span><span class="n">OrderBy</span><span class="p">(</span><span class="n">x</span> <span class="p">=></span> <span class="n">x</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">));</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> London, Tel Aviv</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'query2' 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">AggregationRequest</span> <span class="n">aggRequest</span> <span class="p">=</span> <span class="k">new</span> <span class="n">AggregationRequest</span><span class="p">(</span><span class="s">"*"</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">.</span><span class="n">GroupBy</span><span class="p">(</span><span class="s">"@city"</span><span class="p">,</span> <span class="n">Reducers</span><span class="p">.</span><span class="n">Count</span><span class="p">().</span><span class="n">As</span><span class="p">(</span><span class="s">"count"</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">AggregationResult</span> <span class="n">aggResult</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">FT</span><span class="p">().</span><span class="n">Aggregate</span><span class="p">(</span><span class="s">"idx:users"</span><span class="p">,</span> <span class="n">aggRequest</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">IReadOnlyList</span><span class="p"><</span><span class="n">Dictionary</span><span class="p"><</span><span class="kt">string</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">>></span> <span class="n">resultsList</span> <span class="p">=</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">aggResult</span><span class="p">.</span><span class="n">GetResults</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">for</span> <span class="p">(</span><span class="kt">var</span> <span class="n">i</span> <span class="p">=</span> <span class="m">0</span><span class="p">;</span> <span class="n">i</span> <span class="p"><</span> <span class="n">resultsList</span><span class="p">.</span><span class="n">Count</span><span class="p">;</span> <span class="n">i</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="n">Dictionary</span><span class="p"><</span><span class="kt">string</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">></span> <span class="n">item</span> <span class="p">=</span> <span class="n">resultsList</span><span class="p">.</span><span class="n">ElementAt</span><span class="p">(</span><span class="n">i</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">$"{item["</span><span class="n">city</span><span class="s">"]} - {item["</span><span class="n">count</span><span class="s">"]}"</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="c1">// >>> London - 1</span>
</span></span><span class="line hl"><span class="cl"> <span class="c1">// >>> Tel Aviv - 2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'query3' 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_cs_home_json-stepquery3')" 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_cs_home_json-stepquery3" 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/HomeJsonExample.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>
See the
<a href="/docs/latest/develop/interact/search-and-query/">
Redis query engine
</a>
docs
for a full description of all query features with examples.
</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/dotnet/queryjson/"/>
<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/gears-v1/jvm/classes/readers/javareader/.html | <section class="prose w-full py-12 max-w-none">
<h1>
JavaReader
</h1>
<p class="text-lg -mt-5 mb-10">
A template for creating custom readers.
</p>
<p>
The
<code>
JavaReader
</code>
is an abstract class that allows you to create a custom reader in Java.
</p>
<h2 id="create-a-custom-reader">
Create a custom reader
</h2>
<p>
To create a custom reader:
</p>
<ul>
<li>
Extend the
<code>
JavaReader
</code>
class
</li>
<li>
Override the
<code>
iterator()
</code>
function
</li>
</ul>
<h2 id="custom-reader-example">
Custom reader example
</h2>
<p>
The implementation of the
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/gears-v1/jvm/classes/readers/keysonlyreader/">
<code>
KeysOnlyReader
</code>
</a>
class shows how to create a custom reader with
<code>
JavaReader
</code>
:
</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">java.util.Iterator</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">gears.GearsBuilder</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="cm">/**
</span></span></span><span class="line"><span class="cl"><span class="cm"> * A reader that only reads key names from the key space
</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="kd">public</span> <span class="kd">class</span> <span class="nc">KeysOnlyReader</span> <span class="kd">extends</span> <span class="n">JavaReader</span><span class="o"><</span><span class="n">String</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="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="kd">private</span> <span class="kd">static</span> <span class="kd">final</span> <span class="kt">long</span> <span class="n">serialVersionUID</span> <span class="o">=</span> <span class="mi">1L</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kd">private</span> <span class="n">String</span> <span class="n">scanSize</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"> <span class="kd">private</span> <span class="n">String</span> <span class="n">pattern</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="cm">/**
</span></span></span><span class="line"><span class="cl"><span class="cm"> * Create a new KeysOnlyReader reader
</span></span></span><span class="line"><span class="cl"><span class="cm"> * @param scanSize - the size to use with the scan command
</span></span></span><span class="line"><span class="cl"><span class="cm"> * @param pattern - the pattern of the keys to read
</span></span></span><span class="line"><span class="cl"><span class="cm"> */</span>
</span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="nf">KeysOnlyReader</span><span class="o">(</span><span class="kt">int</span> <span class="n">scanSize</span><span class="o">,</span> <span class="n">String</span> <span class="n">pattern</span><span class="o">)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">this</span><span class="o">.</span><span class="na">scanSize</span> <span class="o">=</span> <span class="n">Integer</span><span class="o">.</span><span class="na">toString</span><span class="o">(</span><span class="n">scanSize</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="k">this</span><span class="o">.</span><span class="na">pattern</span> <span class="o">=</span> <span class="n">pattern</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></span><span class="line"><span class="cl"> <span class="cm">/**
</span></span></span><span class="line"><span class="cl"><span class="cm"> * Create a new KeysOnlyReader reader with default pattern (*) and default
</span></span></span><span class="line"><span class="cl"><span class="cm"> * scan size (10000)
</span></span></span><span class="line"><span class="cl"><span class="cm"> */</span>
</span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="nf">KeysOnlyReader</span><span class="o">()</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">this</span><span class="o">(</span><span class="mi">10000</span><span class="o">,</span> <span class="s">"*"</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></span><span class="line"><span class="cl"> <span class="nd">@Override</span>
</span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="n">Iterator</span><span class="o"><</span><span class="n">String</span><span class="o">></span> <span class="nf">iterator</span><span class="o">()</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">return</span> <span class="k">new</span> <span class="n">Iterator</span><span class="o"><</span><span class="n">String</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">String</span> <span class="n">cursor</span> <span class="o">=</span> <span class="s">"0"</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"> <span class="kt">int</span> <span class="n">currIndex</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">Object</span><span class="o">[]</span> <span class="n">keys</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"> <span class="kt">boolean</span> <span class="n">isDone</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">nextKey</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kd">private</span> <span class="n">String</span> <span class="nf">innerNext</span><span class="o">()</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">while</span><span class="o">(!</span><span class="n">isDone</span><span class="o">)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">if</span><span class="o">(</span><span class="n">keys</span> <span class="o">==</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">Object</span><span class="o">[]</span> <span class="n">res</span> <span class="o">=</span> <span class="o">(</span><span class="n">Object</span><span class="o">[])</span> <span class="n">GearsBuilder</span><span class="o">.</span><span class="na">execute</span><span class="o">(</span><span class="s">"scan"</span><span class="o">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">cursor</span> <span class="o">==</span> <span class="kc">null</span> <span class="o">?</span> <span class="s">"0"</span> <span class="o">:</span> <span class="n">cursor</span><span class="o">,</span>
</span></span><span class="line"><span class="cl"> <span class="s">"MATCH"</span><span class="o">,</span> <span class="n">pattern</span><span class="o">,</span> <span class="s">"COUNT"</span><span class="o">,</span> <span class="n">scanSize</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">keys</span> <span class="o">=</span> <span class="o">(</span><span class="n">Object</span><span class="o">[])</span><span class="n">res</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">cursor</span> <span class="o">=</span> <span class="o">(</span><span class="n">String</span><span class="o">)</span><span class="n">res</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">currIndex</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></span><span class="line"><span class="cl"> <span class="k">if</span><span class="o">(</span><span class="n">currIndex</span> <span class="o"><</span> <span class="n">keys</span><span class="o">.</span><span class="na">length</span><span class="o">)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">return</span> <span class="o">(</span><span class="n">String</span><span class="o">)</span> <span class="n">keys</span><span class="o">[</span><span class="n">currIndex</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></span><span class="line"><span class="cl"> <span class="n">keys</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"> <span class="k">if</span><span class="o">(</span><span class="n">cursor</span><span class="o">.</span><span class="na">charAt</span><span class="o">(</span><span class="mi">0</span><span class="o">)</span> <span class="o">==</span> <span class="sc">'0'</span><span class="o">)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">isDone</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></span><span class="line"><span class="cl"> <span class="o">}</span>
</span></span><span class="line"><span class="cl"> <span class="k">return</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></span><span class="line"><span class="cl"> <span class="nd">@Override</span>
</span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">boolean</span> <span class="nf">hasNext</span><span class="o">()</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">if</span><span class="o">(</span><span class="n">nextKey</span> <span class="o">==</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">nextKey</span> <span class="o">=</span> <span class="n">innerNext</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="k">return</span> <span class="o">!</span><span class="n">isDone</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></span><span class="line"><span class="cl"> <span class="nd">@Override</span>
</span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="n">String</span> <span class="nf">next</span><span class="o">()</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">temp</span> <span class="o">=</span> <span class="n">nextKey</span> <span class="o">!=</span> <span class="kc">null</span> <span class="o">?</span> <span class="n">nextKey</span> <span class="o">:</span> <span class="n">innerNext</span><span class="o">();</span>
</span></span><span class="line"><span class="cl"> <span class="n">nextKey</span> <span class="o">=</span> <span class="n">innerNext</span><span class="o">();</span>
</span></span><span class="line"><span class="cl"> <span class="k">return</span> <span class="n">temp</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></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><span class="line"><span class="cl"><span class="o">}</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/oss_and_stack/stack-with-enterprise/gears-v1/jvm/classes/readers/javareader/"/>
<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/restart/.html | <section class="prose w-full py-12 max-w-none">
<h1>
rladmin restart
</h1>
<p class="text-lg -mt-5 mb-10">
Restarts Redis Enterprise Software processes for a specific database.
</p>
<p>
Schedules a restart of the Redis Enterprise Software processes on primary and replica instances of a specific database.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin restart db <span class="o">{</span> db:<id> <span class="p">|</span> <name> <span class="o">}</span>
</span></span><span class="line"><span class="cl"> <span class="o">[</span>preserve_roles<span class="o">]</span>
</span></span><span class="line"><span class="cl"> <span class="o">[</span>discard_data<span class="o">]</span>
</span></span><span class="line"><span class="cl"> <span class="o">[</span>force_discard<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:<id>
<br/>
name
</td>
<td>
Restarts Redis Enterprise Software processes for the specified database
</td>
</tr>
<tr>
<td>
discard_data
</td>
<td>
</td>
<td>
Allows discarding data if there is no persistence or replication
</td>
</tr>
<tr>
<td>
force_discard
</td>
<td>
</td>
<td>
Forcibly discards data even if there is persistence or replication
</td>
</tr>
<tr>
<td>
preserve_roles
</td>
<td>
</td>
<td>
Performs an additional failover to maintain shard roles
</td>
</tr>
</tbody>
</table>
<h3 id="returns">
Returns
</h3>
<p>
Returns
<code>
Done
</code>
if the restart completed successfully. Otherwise, it returns an error.
</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 restart db db:5 preserve_roles
</span></span><span class="line"><span class="cl">Monitoring 1db07491-35da-4bb6-9bc1-56949f4c312a
</span></span><span class="line"><span class="cl">active - SMUpgradeBDB init
</span></span><span class="line"><span class="cl">active - SMUpgradeBDB stop_forwarding
</span></span><span class="line"><span class="cl">active - SMUpgradeBDB stop_active_expire
</span></span><span class="line"><span class="cl">active - SMUpgradeBDB check_slave
</span></span><span class="line"><span class="cl">oactive - SMUpgradeBDB stop_active_expire
</span></span><span class="line"><span class="cl">active - SMUpgradeBDB second_failover
</span></span><span class="line"><span class="cl">completed - SMUpgradeBDB
</span></span><span class="line"><span class="cl">Done
</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/restart/"/>
<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/xack/.html | <section class="prose w-full py-12">
<h1 class="command-name">
XACK
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">XACK key group id [id ...]</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(1) for each message ID processed.
</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>
@stream
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@fast
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
The
<code>
XACK
</code>
command removes one or multiple messages from the
<em>
Pending Entries List
</em>
(PEL) of a stream consumer group. A message is pending,
and as such stored inside the PEL, when it was delivered to some consumer,
normally as a side effect of calling
<a href="/docs/latest/commands/xreadgroup/">
<code>
XREADGROUP
</code>
</a>
, or when a consumer took
ownership of a message calling
<a href="/docs/latest/commands/xclaim/">
<code>
XCLAIM
</code>
</a>
. The pending message was delivered to
some consumer but the server is yet not sure it was processed at least once.
So new calls to
<a href="/docs/latest/commands/xreadgroup/">
<code>
XREADGROUP
</code>
</a>
to grab the messages history for a consumer
(for instance using an ID of 0), will return such message.
Similarly the pending message will be listed by the
<a href="/docs/latest/commands/xpending/">
<code>
XPENDING
</code>
</a>
command,
that inspects the PEL.
</p>
<p>
Once a consumer
<em>
successfully
</em>
processes a message, it should call
<code>
XACK
</code>
so that such message does not get processed again, and as a side effect,
the PEL entry about this message is also purged, releasing memory from the
Redis server.
</p>
<h2 id="examples">
Examples
</h2>
<pre tabindex="0"><code>redis> XACK mystream mygroup 1526569495631-0
(integer) 1
</code></pre>
<h2 id="resp2resp3-reply">
RESP2/RESP3 Reply
</h2>
<a href="../../develop/reference/protocol-spec#integers">
Integer reply
</a>
: The command returns the number of messages successfully acknowledged. Certain message IDs may no longer be part of the PEL (for example because they have already been acknowledged), and XACK will not count them as successfully acknowledged.
<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/xack/"/>
<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/rs-archive/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Archive
</h1>
<p class="text-lg -mt-5 mb-10">
Describes where to view the archive of Redis Enterprise Software documentation.
</p>
<p>
Previous versions of Redis Enterprise Software documentation are available on the archived web site:
</p>
<ul>
<li>
<p>
<a href="https://docs.redis.com/7.4/rs/">
Redis Enterprise Software v7.4 documentation archive
</a>
</p>
</li>
<li>
<p>
<a href="https://docs.redis.com/7.2/rs/">
Redis Enterprise Software v7.2 documentation archive
</a>
</p>
</li>
<li>
<p>
<a href="https://docs.redis.com/6.4/rs/">
Redis Enterprise Software v6.4 documentation archive
</a>
</p>
</li>
<li>
<p>
<a href="https://docs.redis.com/6.2/rs/">
Redis Enterprise Software v6.2 documentation archive
</a>
</p>
</li>
<li>
<p>
<a href="https://docs.redis.com/6.0/rs/">
Redis Enterprise Software v6.0 documentation archive
</a>
</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/7.4/rs-archive/"/>
<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/bloom/release-notes/.html | <section class="prose w-full py-12 max-w-none">
<h1>
RedisBloom release notes
</h1>
<p class="text-lg -mt-5 mb-10">
RedisBloom release notes for version 2.8 and earlier
</p>
<table>
<thead>
<tr>
<th style="text-align:left">
VersionΒ (ReleaseΒ date)
</th>
<th style="text-align:left">
MajorΒ changes
</th>
<th style="text-align:left">
MinΒ Redis
<br/>
version
</th>
<th style="text-align:left">
MinΒ cluster
<br/>
version
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisbloom/redisbloom-2.8-release-notes/">
v2.8 (July 2024)
</a>
</td>
<td style="text-align:left">
RedisBloom 2.8 introduces improvements and bug fixes.
</td>
<td style="text-align:left">
7.4
</td>
<td style="text-align:left">
7.6 (TBD)
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisbloom/redisbloom-2.6-release-notes/">
v2.6 (July 2023)
</a>
</td>
<td style="text-align:left">
RESP3 support. Bug fixes.
</td>
<td style="text-align:left">
7.2
</td>
<td style="text-align:left">
7.2.4
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisbloom/redisbloom-2.4-release-notes/">
v2.4 (November 2022)
</a>
</td>
<td style="text-align:left">
Added t-digest - a probabilistic data structure for estimating quantiles based on a data stream or a large dataset of floating-point values.
</td>
<td style="text-align:left">
6.0.16
</td>
<td style="text-align:left">
6.2.8
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisbloom/redisbloom-2.2-release-notes/">
v2.2 (December 2019)
</a>
</td>
<td style="text-align:left">
BF.INFO returns bloom filter details. CF.INFO returns cuckoo filter details. Scalable bloom and cuckoo filters. Configurable bucket size for cuckoo filters. CMS.INCRBY returns count.
</td>
<td style="text-align:left">
4.0.0
</td>
<td style="text-align:left">
5.0.0
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisbloom/redisbloom-2.0-release-notes/">
v2.0 (June 2019)
</a>
</td>
<td style="text-align:left">
Added more probabilistic data structures, including top-K and count-min sketch.
</td>
<td style="text-align:left">
4.0.0
</td>
<td style="text-align:left">
5.0.0
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisbloom/redisbloom-1.1-release-notes/">
v1.1 (February 2019)
</a>
</td>
<td style="text-align:left">
Updated version.
</td>
<td style="text-align:left">
4.0.0
</td>
<td style="text-align:left">
5.0.0
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisbloom/redisbloom-1.0-release-notes/">
v1.0 (September 2017)
</a>
</td>
<td style="text-align:left">
First GA release of RedisBloom.
</td>
<td style="text-align:left">
4.0.0
</td>
<td style="text-align:left">
5.0.0
</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/oss_and_stack/stack-with-enterprise/release-notes/redisbloom/"/>
<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/stats/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Cluster stats requests
</h1>
<p class="text-lg -mt-5 mb-10">
Cluster statistics requests
</p>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="#get-cluster-stats">
GET
</a>
</td>
<td>
<code>
/v1/cluster/stats
</code>
</td>
<td>
Get cluster stats
</td>
</tr>
</tbody>
</table>
<h2 id="get-cluster-stats">
Get cluster stats
</h2>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">GET /v1/cluster/stats
</span></span></code></pre>
</div>
<p>
Get cluster statistics.
</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/7.4/references/rest-api/permissions/#view_cluster_stats">
view_cluster_stats
</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 /cluster/stats/1?interval<span class="o">=</span>1hour<span class="p">&</span><span class="nv">stime</span><span class="o">=</span>2014-08-28T10:00:00Z
</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="query-parameters">
Query parameters
</h4>
<table>
<thead>
<tr>
<th>
Field
</th>
<th>
Type
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
interval
</td>
<td>
string
</td>
<td>
Time interval for which we want stats: 1sec/10sec/5min/15min/1hour/12hour/1week (optional)
</td>
</tr>
<tr>
<td>
stime
</td>
<td>
ISO_8601
</td>
<td>
Start time from which we want the stats. Should comply with the
<a href="https://en.wikipedia.org/wiki/ISO_8601">
ISO_8601
</a>
format (optional)
</td>
</tr>
<tr>
<td>
etime
</td>
<td>
ISO_8601
</td>
<td>
End time after which we don't want the stats. Should comply with the
<a href="https://en.wikipedia.org/wiki/ISO_8601">
ISO_8601
</a>
format (optional)
</td>
</tr>
</tbody>
</table>
<h3 id="get-response">
Response
</h3>
<p>
Returns
<a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/statistics/">
statistics
</a>
for the cluster.
</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="nt">"intervals"</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">"interval"</span><span class="p">:</span> <span class="s2">"1hour"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"stime"</span><span class="p">:</span> <span class="s2">"2015-05-27T12:00:00Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"etime"</span><span class="p">:</span> <span class="s2">"2015-05-28T12:59:59Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"conns"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"cpu_idle"</span><span class="p">:</span> <span class="mf">0.8533959401503577</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"cpu_system"</span><span class="p">:</span> <span class="mf">0.01602159448549579</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"cpu_user"</span><span class="p">:</span> <span class="mf">0.08721123782294203</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"egress_bytes"</span><span class="p">:</span> <span class="mf">1111.2184745131947</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"ephemeral_storage_avail"</span><span class="p">:</span> <span class="mf">3406676307.1449075</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"ephemeral_storage_free"</span><span class="p">:</span> <span class="mf">4455091440.360014</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"free_memory"</span><span class="p">:</span> <span class="mf">2745470765.673594</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"ingress_bytes"</span><span class="p">:</span> <span class="mf">220.84083194769272</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"interval"</span><span class="p">:</span> <span class="s2">"1week"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"persistent_storage_avail"</span><span class="p">:</span> <span class="mf">3406676307.1533995</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"persistent_storage_free"</span><span class="p">:</span> <span class="mf">4455091440.088265</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"total_req"</span><span class="p">:</span> <span class="mf">0.0</span>
</span></span><span class="line"><span class="cl"> <span class="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">"interval"</span><span class="p">:</span> <span class="s2">"1hour"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"stime"</span><span class="p">:</span> <span class="s2">"2015-05-27T13:00:00Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"etime"</span><span class="p">:</span> <span class="s2">"2015-05-28T13:59:59Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"// additional fields..."</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><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>
<h3 id="example-requests">
Example requests
</h3>
<h4 id="curl">
cURL
</h4>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ curl -k -u <span class="s2">"[username]:[password]"</span> -X GET
</span></span><span class="line"><span class="cl"> https://<span class="o">[</span>host<span class="o">][</span>:port<span class="o">]</span>/v1/cluster/stats?interval<span class="o">=</span>1hour
</span></span></code></pre>
</div>
<h4 id="python">
Python
</h4>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">requests</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">url</span> <span class="o">=</span> <span class="s2">"https://[host][:port]/v1/cluster/stats?interval=1hour"</span>
</span></span><span class="line"><span class="cl"><span class="n">auth</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"[username]"</span><span class="p">,</span> <span class="s2">"[password]"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">response</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">request</span><span class="p">(</span><span class="s2">"GET"</span><span class="p">,</span> <span class="n">url</span><span class="p">,</span> <span class="n">auth</span><span class="o">=</span><span class="n">auth</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">response</span><span class="o">.</span><span class="n">text</span><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>
No error
</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>
Internal server error
</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/stats/"/>
<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/peer_stats/.html | <section class="prose w-full py-12 max-w-none">
<h1>
CRDB peer stats requests
</h1>
<p class="text-lg -mt-5 mb-10">
Active-Active peer instance statistics requests
</p>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="#get-all-bdbs-peer_stats">
GET
</a>
</td>
<td>
<code>
/v1/bdbs/{bdb_uid}/peer_stats
</code>
</td>
<td>
Get stats for all CRDB peer instances
</td>
</tr>
<tr>
<td>
<a href="#get-bdbs-peer_stats">
GET
</a>
</td>
<td>
<code>
/v1/bdbs/{bdb_uid}/peer_stats/{uid}
</code>
</td>
<td>
Get stats for a specific CRDB peer instance
</td>
</tr>
</tbody>
</table>
<h2 id="get-all-bdbs-peer_stats">
Get all CRDB peer stats
</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>bdb_uid<span class="o">}</span>/peer_stats
</span></span></code></pre>
</div>
<p>
Get statistics for all peer instances of a local CRDB instance.
</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/#view_bdb_stats">
view_bdb_stats
</a>
</td>
<td>
admin
<br/>
cluster_member
<br/>
cluster_viewer
<br/>
db_member
<br/>
db_viewer
<br/>
user_manager
</td>
</tr>
</tbody>
</table>
<h3 id="get-all-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/peer_stats?interval<span class="o">=</span>5min
</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>
bdb_uid
</td>
<td>
integer
</td>
<td>
The unique ID of the local CRDB instance.
</td>
</tr>
</tbody>
</table>
<h4 id="query-parameters">
Query parameters
</h4>
<table>
<thead>
<tr>
<th>
Field
</th>
<th>
Type
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
interval
</td>
<td>
string
</td>
<td>
Time interval for which we want stats: 1sec/10sec/5min/15min/1hour/12hour/1week (optional)
</td>
</tr>
<tr>
<td>
stime
</td>
<td>
ISO_8601
</td>
<td>
Start time from which we want the stats. Should comply with the
<a href="https://en.wikipedia.org/wiki/ISO_8601">
ISO_8601
</a>
format (optional)
</td>
</tr>
<tr>
<td>
etime
</td>
<td>
ISO_8601
</td>
<td>
End time after which we don't want the stats. Should comply with the
<a href="https://en.wikipedia.org/wiki/ISO_8601">
ISO_8601
</a>
format (optional)
</td>
</tr>
</tbody>
</table>
<h3 id="get-all-response">
Response
</h3>
<p>
Returns
<a href="/docs/latest/operate/rs/references/rest-api/objects/statistics/">
statistics
</a>
for all CRDB peer instances.
</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 class="nt">"peer_stats"</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">"intervals"</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">"egress_bytes"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"egress_bytes_decompressed"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"etime"</span><span class="p">:</span> <span class="s2">"2017-10-22T19:30:00Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"ingress_bytes"</span><span class="p">:</span> <span class="mi">18528</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"ingress_bytes_decompressed"</span><span class="p">:</span> <span class="mi">185992</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"interval"</span><span class="p">:</span> <span class="s2">"5min"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"local_ingress_lag_time"</span><span class="p">:</span> <span class="mf">0.244</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"pending_local_writes_max"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"pending_local_writes_min"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"stime"</span><span class="p">:</span> <span class="s2">"2017-10-22T19:25:00Z"</span>
</span></span><span class="line"><span class="cl"> <span class="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">"egress_bytes"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"egress_bytes_decompressed"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"etime"</span><span class="p">:</span> <span class="s2">"2017-10-22T19:35:00Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"ingress_bytes"</span><span class="p">:</span> <span class="mi">18</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"ingress_bytes_decompressed"</span><span class="p">:</span> <span class="mi">192</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"interval"</span><span class="p">:</span> <span class="s2">"5min"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"local_ingress_lag_time"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"pending_local_writes_max"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"pending_local_writes_min"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"stime"</span><span class="p">:</span> <span class="s2">"2017-10-22T19:30:00Z"</span>
</span></span><span class="line"><span class="cl"> <span class="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">"uid"</span><span class="p">:</span> <span class="s2">"3"</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><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="get-all-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 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>
Database is not a CRDB.
</td>
</tr>
</tbody>
</table>
<h2 id="get-bdbs-peer_stats">
Get CRDB peer stats
</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>bdb_uid<span class="o">}</span>/peer_stats/<span class="o">{</span>int: uid<span class="o">}</span>
</span></span></code></pre>
</div>
<p>
Get statistics for a specific CRDB peer instance.
</p>
<h3 id="permissions-1">
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/#view_bdb_stats">
view_bdb_stats
</a>
</td>
<td>
admin
<br/>
cluster_member
<br/>
cluster_viewer
<br/>
db_member
<br/>
db_viewer
<br/>
user_manager
</td>
</tr>
</tbody>
</table>
<h3 id="get-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">GET /bdbs/1/peer_stats/3?interval<span class="o">=</span>5min
</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>
</tbody>
</table>
<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>
bdb_uid
</td>
<td>
integer
</td>
<td>
The unique ID of the local CRDB instance.
</td>
</tr>
<tr>
<td>
uid
</td>
<td>
integer
</td>
<td>
The peer instance uid, as specified in the CRDB instance list.
</td>
</tr>
</tbody>
</table>
<h4 id="query-parameters-1">
Query parameters
</h4>
<table>
<thead>
<tr>
<th>
Field
</th>
<th>
Type
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
interval
</td>
<td>
string
</td>
<td>
Time interval for which we want stats: 1sec/10sec/5min/15min/1hour/12hour/1week (optional)
</td>
</tr>
<tr>
<td>
stime
</td>
<td>
ISO_8601
</td>
<td>
Start time from which we want the stats. Should comply with the
<a href="https://en.wikipedia.org/wiki/ISO_8601">
ISO_8601
</a>
format (optional)
</td>
</tr>
<tr>
<td>
etime
</td>
<td>
ISO_8601
</td>
<td>
End time after which we don't want the stats. Should comply with the
<a href="https://en.wikipedia.org/wiki/ISO_8601">
ISO_8601
</a>
format (optional)
</td>
</tr>
</tbody>
</table>
<h3 id="get-response">
Response
</h3>
<p>
Returns
<a href="/docs/latest/operate/rs/references/rest-api/objects/statistics/">
statistics
</a>
for a specific CRDB peer instance.
</p>
<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">"intervals"</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">"egress_bytes"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"egress_bytes_decompressed"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"etime"</span><span class="p">:</span> <span class="s2">"2017-10-22T19:30:00Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"ingress_bytes"</span><span class="p">:</span> <span class="mi">18528</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"ingress_bytes_decompressed"</span><span class="p">:</span> <span class="mi">185992</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"interval"</span><span class="p">:</span> <span class="s2">"5min"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"local_ingress_lag_time"</span><span class="p">:</span> <span class="mf">0.244</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"pending_local_writes_max"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"pending_local_writes_min"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"stime"</span><span class="p">:</span> <span class="s2">"2017-10-22T19:25:00Z"</span>
</span></span><span class="line"><span class="cl"> <span class="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">"egress_bytes"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"egress_bytes_decompressed"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"etime"</span><span class="p">:</span> <span class="s2">"2017-10-22T19:35:00Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"ingress_bytes"</span><span class="p">:</span> <span class="mi">18</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"ingress_bytes_decompressed"</span><span class="p">:</span> <span class="mi">192</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"interval"</span><span class="p">:</span> <span class="s2">"5min"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"local_ingress_lag_time"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"pending_local_writes_max"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"pending_local_writes_min"</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"stime"</span><span class="p">:</span> <span class="s2">"2017-10-22T19:30:00Z"</span>
</span></span><span class="line"><span class="cl"> <span class="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">"uid"</span><span class="p">:</span> <span class="s2">"3"</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>
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 or peer 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>
Database is not a CRDB.
</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/peer_stats/"/>
<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/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Manage databases
</h1>
<p class="text-lg -mt-5 mb-10">
This page will help you find database management information in the Databases section.
</p>
<p>
You can manage your Redis Enterprise Software databases with several different tools:
</p>
<ul>
<li>
Cluster Manager UI (the web-based user interface)
</li>
<li>
Command-line tools (
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/rladmin/">
<code>
rladmin
</code>
</a>
,
<a href="/docs/latest/develop/tools/cli/">
<code>
redis-cli
</code>
</a>
,
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/crdb-cli/">
<code>
crdb-cli
</code>
</a>
)
</li>
<li>
<a href="/docs/latest/operate/rs/7.4/references/rest-api/">
REST API
</a>
</li>
</ul>
<nav>
<a href="/docs/latest/operate/rs/7.4/databases/create/">
Create a Redis Enterprise Software database
</a>
<p>
Create a database with Redis Enterprise Software.
</p>
<a href="/docs/latest/operate/rs/7.4/databases/configure/">
Configure database settings
</a>
<p>
Configure settings specific to each database.
</p>
<a href="/docs/latest/operate/rs/7.4/databases/connect/">
Connect to a database
</a>
<p>
Learn how to connect your application to a Redis database hosted by Redis Enterprise Software and test your connection.
</p>
<a href="/docs/latest/operate/rs/7.4/databases/import-export/">
Import and export data
</a>
<p>
How to import, export, flush, and migrate your data.
</p>
<a href="/docs/latest/operate/rs/7.4/databases/migrate-shards/">
Migrate database shards
</a>
<p>
How to migrate database shards to other nodes in a Redis Software cluster.
</p>
<a href="/docs/latest/operate/rs/7.4/databases/recover/">
Recover a failed database
</a>
<p>
Recover a database after the cluster fails or the database is corrupted.
</p>
<a href="/docs/latest/operate/rs/7.4/databases/delete/">
Delete databases
</a>
<p>
Delete a database from the Cluster Manager UI.
</p>
<a href="/docs/latest/operate/rs/7.4/databases/active-active/">
Active-Active geo-distributed Redis
</a>
<p>
Overview of the Active-Active database in Redis Enterprise Software
</p>
<a href="/docs/latest/operate/rs/7.4/databases/auto-tiering/">
Auto Tiering
</a>
<p>
Auto Tiering enables your data to span both RAM and dedicated flash memory.
</p>
<a href="/docs/latest/operate/rs/7.4/databases/durability-ha/">
Durability and high availability
</a>
<p>
Overview of Redis Enterprise durability features such as replication, clustering, and rack-zone awareness.
</p>
<a href="/docs/latest/operate/rs/7.4/databases/memory-performance/">
Memory and performance
</a>
<p>
Learn more about managing your memory and optimizing performance for your database.
</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/databases/"/>
<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/manage-users/default-user/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Manage default user
</h1>
<p class="text-lg -mt-5 mb-10">
Manage a database's default user.
</p>
<p>
When you
<a href="/docs/latest/operate/rs/databases/create/">
create a database
</a>
, default user database access is enabled by default (
<strong>
Unauthenticated access
</strong>
is selected). This gives the default user full access to the database and enables compatibility with versions of Redis before Redis 6.
</p>
<p>
Select
<strong>
Password-only authentication
</strong>
, then enter and confirm a default database password to require authentication for connections to the database.
</p>
<a href="/docs/latest/images/rs/screenshots/databases/security-access-control-password-only.png" sdata-lightbox="/images/rs/screenshots/databases/security-access-control-password-only.png">
<img alt="Select Password-only authentication to require a password to access the database." src="/docs/latest/images/rs/screenshots/databases/security-access-control-password-only.png"/>
</a>
<h2 id="authenticate-as-default-user">
Authenticate as default user
</h2>
<p>
When you configure a password for your database, all connections to the database must authenticate using the
<a href="/docs/latest/commands/auth/">
AUTH
</a>
command. See Redis security's
<a href="/docs/latest/operate/oss_and_stack/management/security/#authentication">
authentication
</a>
section for more information.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">AUTH <default-database-password>
</span></span></code></pre>
</div>
<h2 id="change-default-database-password">
Change default database password
</h2>
<p>
To change the default user's password:
</p>
<ol>
<li>
<p>
From the database's
<strong>
Security
</strong>
tab, select
<strong>
Edit
</strong>
.
</p>
</li>
<li>
<p>
In the
<strong>
Access Control
</strong>
section, select
<strong>
Password-only authentication
</strong>
as the
<strong>
Access method
</strong>
.
</p>
</li>
<li>
<p>
Enter and re-enter the new password.
</p>
</li>
<li>
<p>
Select
<strong>
Save
</strong>
.
</p>
</li>
</ol>
<h2 id="deactivate-default-user">
Deactivate default user
</h2>
<p>
If you set up
<a href="/docs/latest/operate/rs/security/access-control/">
role-based access control
</a>
with
<a href="/docs/latest/operate/rs/security/access-control/create-db-roles/">
access control lists
</a>
(ACLs) for your database and don't require backwards compatibility with versions earlier than Redis 6, you can
<a href="/docs/latest/operate/rs/security/access-control/manage-users/default-user/">
deactivate the default user
</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">
Warning:
</div>
Before you deactivate default user access, make sure the role associated with the database is
<a href="/docs/latest/operate/rs/security/access-control/create-users/">
assigned to a user
</a>
. Otherwise, the database will be inaccessible.
</div>
</div>
<p>
To deactivate the default user:
</p>
<ol>
<li>
<p>
From the database's
<strong>
Security
</strong>
tab, select
<strong>
Edit
</strong>
.
</p>
</li>
<li>
<p>
In the
<strong>
Access Control
</strong>
section, select
<strong>
Using ACL only
</strong>
as the
<strong>
Access method
</strong>
.
</p>
<a href="/docs/latest/images/rs/screenshots/databases/security-access-control-acl-only.png" sdata-lightbox="/images/rs/screenshots/databases/security-access-control-acl-only.png">
<img alt="Select Using ACL only to deactivate default user access to the database." src="/docs/latest/images/rs/screenshots/databases/security-access-control-acl-only.png"/>
</a>
</li>
<li>
<p>
Choose at least one role and Redis ACL to access the database.
</p>
</li>
<li>
<p>
Select
<strong>
Save
</strong>
.
</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/security/access-control/manage-users/default-user/"/>
<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/gears-v1/jvm/commands/.html | <section class="prose w-full py-12 max-w-none">
<h1>
RedisGears JVM commands
</h1>
<p>
Use a Redis client like
<code>
redis-cli
</code>
to send commands to the RedisGears JVM plugin.
</p>
<h2 id="jvm-plugin-commands">
JVM plugin commands
</h2>
<table>
<thead>
<tr>
<th style="text-align:left">
Command
</th>
<th style="text-align:left">
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/gears-v1/jvm/commands/rg-jdumpsessions/">
RG.JDUMPSESSIONS
</a>
</td>
<td style="text-align:left">
Outputs information about existing Java sessions.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/gears-v1/jvm/commands/rg-jexecute/">
RG.JEXECUTE
</a>
</td>
<td style="text-align:left">
Executes a Java function.
</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>
Ignore any commands that start with
<code>
RG.PY
</code>
while using the JVM plugin. The
<code>
RG.PY
</code>
commands are for the Python plugin.
</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/gears-v1/jvm/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/commands/grouppubsub.html | <section class="prose w-full py-12">
<h1>
Commands
</h1>
</section>
|
https://redis.io/docs/latest/commands/function-load/.html | <section class="prose w-full py-12">
<h1 class="command-name">
FUNCTION LOAD
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">FUNCTION LOAD [REPLACE] function-code</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) (considering compilation time is redundant)
</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>
@slow
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@scripting
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
Load a library to Redis.
</p>
<p>
The command's gets a single mandatory parameter which is the source code that implements the library.
The library payload must start with Shebang statement that provides a metadata about the library (like the engine to use and the library name).
Shebang format:
<code>
#!<engine name> name=<library name>
</code>
. Currently engine name must be
<code>
lua
</code>
.
</p>
<p>
For the Lua engine, the implementation should declare one or more entry points to the library with the
<a href="/docs/latest/develop/interact/programmability/lua-api#redis.register_function">
<code>
redis.register_function()
</code>
API
</a>
.
Once loaded, you can call the functions in the library with the
<a href="/docs/latest/commands/fcall/">
<code>
FCALL
</code>
</a>
(or
<a href="/docs/latest/commands/fcall_ro/">
<code>
FCALL_RO
</code>
</a>
when applicable) command.
</p>
<p>
When attempting to load a library with a name that already exists, the Redis server returns an error.
The
<code>
REPLACE
</code>
modifier changes this behavior and overwrites the existing library with the new contents.
</p>
<p>
The command will return an error in the following circumstances:
</p>
<ul>
<li>
An invalid
<em>
engine-name
</em>
was provided.
</li>
<li>
The library's name already exists without the
<code>
REPLACE
</code>
modifier.
</li>
<li>
A function in the library is created with a name that already exists in another library (even when
<code>
REPLACE
</code>
is specified).
</li>
<li>
The engine failed in creating the library's functions (due to a compilation error, for example).
</li>
<li>
No functions were declared by the library.
</li>
</ul>
<p>
For more information please refer to
<a href="/docs/latest/develop/interact/programmability/functions-intro/">
Introduction to Redis Functions
</a>
.
</p>
<h2 id="examples">
Examples
</h2>
<p>
The following example will create a library named
<code>
mylib
</code>
with a single function,
<code>
myfunc
</code>
, that returns the first argument it gets.
</p>
<pre tabindex="0"><code>redis> FUNCTION LOAD "#!lua name=mylib \n redis.register_function('myfunc', function(keys, args) return args[1] end)"
mylib
redis> FCALL myfunc 0 hello
"hello"
</code></pre>
<h2 id="resp2resp3-reply">
RESP2/RESP3 Reply
</h2>
<a href="../../develop/reference/protocol-spec#bulk-strings">
Bulk string reply
</a>
: the library name that was loaded.
<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/function-load/"/>
<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/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Quick starts
</h1>
<p class="text-lg -mt-5 mb-10">
Redis quick start guides
</p>
<p>
Redis can be used as a database, cache, streaming engine, message broker, and more. The following quick start guides will show you how to use Redis for the following specific purposes:
</p>
<ol>
<li>
<a href="/docs/latest/develop/get-started/data-store/">
Data structure store
</a>
</li>
<li>
<a href="/docs/latest/develop/get-started/document-database/">
Document database
</a>
</li>
<li>
<a href="/docs/latest/develop/get-started/vector-database/">
Vector database
</a>
</li>
</ol>
<p>
Please select the guide that aligns best with your specific usage scenario.
</p>
<p>
You can find answers to frequently asked questions in the
<a href="/docs/latest/develop/get-started/faq/">
FAQ
</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/develop/get-started/"/>
<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/pulumi-provider-for-redis-cloud/get-started/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Get started with Pulumi
</h1>
<p class="text-lg -mt-5 mb-10">
Shows how to install the Redis Cloud Pulumi provider and create a subscription.
</p>
<p>
Here, you'll learn how to use the
<a href="/docs/latest/integrate/pulumi-provider-for-redis-cloud/">
Redis Cloud Pulumi provider
</a>
to create a Redis Cloud Pro subscription and a database using Python.
</p>
<h2 id="prerequisites">
Prerequisites
</h2>
<ol>
<li>
<p>
<a href="https://www.pulumi.com/docs/install/">
Install Pulumi
</a>
and
<a href="https://app.pulumi.com/signin">
create a Pulumi account
</a>
if you do not have one already.
</p>
</li>
<li>
<p>
<a href="/docs/latest/operate/rc/rc-quickstart/#create-an-account">
Create a Redis Cloud account
</a>
if you do not have one already.
</p>
</li>
<li>
<p>
<a href="/docs/latest/operate/rc/api/get-started/enable-the-api/">
Enable the Redis Cloud API
</a>
.
</p>
</li>
<li>
<p>
Get your Redis Cloud
<a href="/docs/latest/operate/rc/api/get-started/manage-api-keys/">
API keys
</a>
.
</p>
</li>
</ol>
<h2 id="install-the-pulumi-provider-files">
Install the Pulumi provider files
</h2>
<ol>
<li>
<p>
In your Python project, create an empty folder. From this folder, run
<code>
pulumi new rediscloud-python
</code>
.
</p>
</li>
<li>
<p>
Log into Pulumi using your
<a href="https://app.pulumi.com/account/tokens">
Pulumi access token
</a>
if prompted.
</p>
</li>
<li>
<p>
Enter a project name, description, and stack name.
</p>
</li>
<li>
<p>
Enter your Redis Cloud access and secret keys.
</p>
</li>
<li>
<p>
Enter the credit card type (Visa, Mastercard) on file with your Redis Cloud account.
</p>
</li>
<li>
<p>
Enter the last four numbers of the card on file with your Redis Cloud account.
</p>
</li>
</ol>
<p>
Once these steps are completed, the dependencies needed for the project will be installed and a Python virtual environment will be created.
</p>
<h2 id="deploy-resources-with-pulumi">
Deploy resources with Pulumi
</h2>
<p>
The Pulumi Python project includes three main files:
</p>
<ul>
<li>
<p>
<code>
pulumi.yaml
</code>
: A metadata file which is used to help configure the Python runtime environment.
</p>
</li>
<li>
<p>
<code>
pulumi.YOUR_PROJECT_NAME.yaml
</code>
: Contains the information related to the Cloud API access and secret key, credit card type and last 4 digits.
</p>
</li>
<li>
<p>
<code>
__main__.py
</code>
: A Pulumi template file that creates a Redis Cloud Pro subscription. Use this template file as a starting point to create the subscription with a cloud provider and define specifications for the database (this includes memory, throughput, Redis advanced capabilities, and other information).
</p>
</li>
</ul>
<p>
To deploy the resources described in
<code>
__main__.py
</code>
, run
<code>
pulumi up
</code>
. This will take some time. You will be able to see your subscription being created through the
<a href="https://cloud.redis.io/">
Redis Cloud console
</a>
.
</p>
<p>
If you want to remove these resources, run
<code>
pulumi down
</code>
.
</p>
<h2 id="more-info">
More info
</h2>
<ul>
<li>
<a href="https://www.pulumi.com/registry/packages/rediscloud/">
Redis Cloud Pulumi registry
</a>
</li>
<li>
<a href="https://www.pulumi.com/docs/">
Pulumi documentation
</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/integrate/pulumi-provider-for-redis-cloud/get-started/"/>
<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/january-2024/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Redis Cloud changelog (January 2024)
</h1>
<p class="text-lg -mt-5 mb-10">
New features, enhancements, and other changes added to Redis Cloud during January 2024.
</p>
<h2 id="new-features">
New features
</h2>
<h3 id="transit-gateway">
Transit Gateway
</h3>
<p>
You can now connect your Flexible subscriptions hosted on Amazon Web Services (AWS) to
<a href="https://docs.aws.amazon.com/vpc/latest/tgw/how-transit-gateways-work.html">
AWS Transit Gateway
</a>
. See
<a href="/docs/latest/operate/rc/security/aws-transit-gateway/">
Connect to Transit Gateway
</a>
to learn how to connect your Flexible subscription to Transit Gateway.
</p>
<h3 id="billing-admin-role">
Billing Admin role
</h3>
<p>
You can now add a user with the Billing Admin role in the
<a href="/docs/latest/operate/rc/security/access-control/access-management/">
Access Management
</a>
screen. Billing Admins can view and edit settings related to billing and payments. They can add and remove payment methods and change the payment method for a subscription, but they cannot change any other subscription or database settings.
</p>
<p>
See
<a href="/docs/latest/operate/rc/security/access-control/access-management/#team-management-roles">
Team Management roles
</a>
to see an overview of user roles and their permissions.
</p>
<h3 id="database-tags">
Database tags
</h3>
<p>
You can now add
<a href="/docs/latest/operate/rc/databases/tag-database/">
tags
</a>
to your database.
</p>
<p>
Tags are key-value pairs that let you categorize your databases. You can create tags and add them to your databases to associate them with each other. Once you've added tags, you can filter your databases in the
<a href="/docs/latest/operate/rc/databases/view-edit-database/#manage-the-database-list">
database list
</a>
by tag key or value.
</p>
<p>
See
<a href="/docs/latest/operate/rc/databases/tag-database/">
Manage tags
</a>
to learn how to add tags to your database.
</p>
<h3 id="network-data-cost-breakdowns">
Network data cost breakdowns
</h3>
<p>
Invoices for customers with Flexible and Annual subscriptions now include a breakdown of network data costs for the subscription. To download an invoice, go to the
<a href="/docs/latest/operate/rc/billing-and-payments/#download-invoice">
Billing and Payments
</a>
page on the
<a href="https://cloud.redis.io/">
Redis Cloud console
</a>
.
</p>
<p>
Customers with Annual subscriptions can also find a breakdown of network data costs in the consumption report.
</p>
<h2 id="deprecations">
Deprecations
</h2>
<ul>
<li>
<p>
As of January 2024, new and upgraded Redis Cloud Essentials subscriptions are limited to one database per subscription. If you have a Redis Cloud Essentials subscription created before January 2024, you can add databases up to the previous plan limit. If you choose to upgrade your plan, you can keep your databases, but you will need to create a new subscription to add another database.
</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/rc/changelog/january-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>
|